Compare commits

...

696 commits

Author SHA1 Message Date
Torsten Grote
25e88caf88
Merge pull request #784 from grote/check-storage
Test for free space and allow 0 response
2024-11-20 13:38:10 -03:00
Torsten Grote
8a00a2939a
Merge pull request #785 from grote/check-app-backup
Verify app backup integrity
2024-11-19 17:10:28 -03:00
Torsten Grote
417531ff49
Don't treat HashMismatchException as a fatal error when restoring
because may just be a corrupted file
2024-11-19 14:28:39 -03:00
Torsten Grote
32aff32c73
Fix FullRestore when Loader#loadFiles() throws an error for a later blob stream. 2024-11-14 14:51:11 -03:00
Torsten Grote
47c3e652c2
Don't include known bad blobs in BlobCache 2024-11-08 10:57:43 -03:00
Torsten Grote
ae77ebed8f
Remove known bad blobs from do-not-use list when deleting them 2024-11-08 10:41:18 -03:00
Torsten Grote
69765c7857
Record known bad blobs on do-not-use list in BlobCache 2024-11-08 10:38:31 -03:00
Torsten Grote
6d9c18bd29
Checker: account for possibility that one chunkId maps to more than one blob 2024-11-01 16:23:54 -03:00
Torsten Grote
4f5199ce27
Make APK backup self-healing 2024-11-01 10:38:29 -03:00
Torsten Grote
15e8850e5e
Don't allow running app data check while backup is running 2024-11-01 10:38:29 -03:00
Torsten Grote
45d710270a
Restrict Checker.concurrencyLimit to 3 when backend requires network 2024-11-01 10:38:28 -03:00
Torsten Grote
166f81b3a8
Add unit tests for Checker 2024-11-01 10:38:28 -03:00
Torsten Grote
beedafd042
Move AppCheckFragment into check package 2024-11-01 10:38:28 -03:00
Torsten Grote
06191a1fc3
Catch error when loading snapshots for app checking 2024-11-01 10:38:28 -03:00
Torsten Grote
83974b4121
Show app backup check error screen
and error notification
2024-11-01 10:38:27 -03:00
Torsten Grote
26063a8ef0
Show app backup check success screen 2024-11-01 10:38:27 -03:00
Torsten Grote
96f9a8d017
Show app backup check success notification 2024-11-01 10:38:27 -03:00
Torsten Grote
51a6355205
Do parallel checking and update notification with progress 2024-11-01 10:38:26 -03:00
Torsten Grote
591dfe0bd6
Implement actual checking 2024-11-01 10:38:26 -03:00
Torsten Grote
85ce587b14
Create AppCheckerWorker and wire it up 2024-11-01 10:38:25 -03:00
Torsten Grote
060bb425da
UI for checking app backups 2024-11-01 10:38:25 -03:00
Torsten Grote
f67c1d5544
Replace deprecated sharedViewModel by activityViewModel 2024-11-01 10:38:24 -03:00
Torsten Grote
e19be55f83
Merge pull request #786 from grote/show-app-size
Show 'Launch' button for force stopped apps in backup status screen
2024-10-31 16:27:16 -03:00
Torsten Grote
13e3dadeb4
Show 'Launch' button for force stopped apps
in backup status screen.
2024-10-30 12:15:53 -03:00
Torsten Grote
f1224f09f8
Test for free space and allow 0 2024-10-22 17:35:43 -03:00
Torsten Grote
0fa14025b3
Merge pull request #748 from seedvault-app/feature/cirrus-ci-tests
Run tests in Cirrus CI again
2024-10-18 10:34:18 -03:00
Torsten Grote
d96bc52192
Merge pull request #691 from grote/690-webdav-info
Show full URL in settings when WebDAV is used
2024-10-17 15:54:45 -03:00
Torsten Grote
0ed6d5c2c0
Don't show toolbar for recovery code when restoring
This restores original behavior and should make CI pass which otherwise can't see the last two words.
2024-10-17 15:19:33 -03:00
Torsten Grote
a538a64395
Use DigestInputStream to spy on backup data
this is to save memory to prevent OOM errors we saw on CI
2024-10-17 13:51:31 -03:00
Torsten Grote
1d17adedff
log stopped packages in CI test 2024-10-17 13:51:31 -03:00
Torsten Grote
b8c87a6928
Always log BackupMonitor and start stopped apps later in CI test 2024-10-17 13:51:31 -03:00
Torsten Grote
32d7f49d4c
show error notification when AppBackupWorker isn't successful
otherwise there's no UI feedback when running backup manually
2024-10-17 13:51:31 -03:00
Torsten Grote
2957678465
Fix potential thread-safety issue when changing backends 2024-10-17 13:51:30 -03:00
Torsten Grote
3d9eca0d40
adapt CI to new UI for restore set items 2024-10-17 13:51:30 -03:00
Torsten Grote
eb9dad798c
onBackupSuccess now doesn't need a boolean anymore 2024-10-17 13:51:30 -03:00
Torsten Grote
623eb331da
Ignore contactsbackup BackupRestoreTest if we don't have the correct permissions 2024-10-17 13:51:30 -03:00
Torsten Grote
9e5f22a8a0
Install contactsbackup before restart, so default permissions get applied
Also add testkey for signed builds
2024-10-17 13:51:30 -03:00
Torsten Grote
910c68aa52
Launch stopped apps before test to ensure they get backed up 2024-10-17 13:51:29 -03:00
Torsten Grote
f38bed9616
Run instrumentation tests from other gradle modules
and those not annotated with @MediumTest
2024-10-17 13:51:29 -03:00
Steve Soltys
8234cd8196
Add contactsbackup permissions to test emulator 2024-10-17 13:51:29 -03:00
Steve Soltys
315e0736f5
Fix KVRestore spies to use new functions 2024-10-17 13:51:29 -03:00
Steve Soltys
42d7747641
Add logging for unknown exceptions 2024-10-17 13:51:29 -03:00
Steve Soltys
4aeb05813d
Run tests in Cirrus CI again 2024-10-17 13:51:26 -03:00
Torsten Grote
3fd615477d
Merge pull request #776 from theimpulson/menu
Switch to toolbar APIs for working with menu
2024-10-17 13:41:18 -03:00
Torsten Grote
1299008780
Merge pull request #781 from grote/exclude-us
Exclude ourselves from backup status
2024-10-16 12:51:04 -03:00
Aayush Gupta
d86ecd303d storage: demo: Adjust for edge to edge support
Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
2024-10-16 20:31:47 +05:30
Aayush Gupta
bfdb297ca4 storage: demo: Inherit M3 theme
Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
2024-10-16 20:31:47 +05:30
Aayush Gupta
2b5ca5ebdc {app|storage}: Drop theme attribute from toolbar
Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
2024-10-16 20:31:47 +05:30
Aayush Gupta
82267f6844 app: Switch to toolbar APIs for working with menu
Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
2024-10-16 20:31:46 +05:30
Aayush Gupta
a5fe52a01f storage: demo: Switch to toolbar APIs for working with menu
Activity methods have been deprecated

Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
2024-10-16 20:21:40 +05:30
Torsten Grote
321c04958c
Exclude ourselves from backup status 2024-10-16 08:54:41 -03:00
Torsten Grote
f52b1004fb
Show full URL in settings when WebDAV is used 2024-10-15 17:47:40 -03:00
Torsten Grote
f5c2f0bd3a Release version 15-5.0 2024-10-16 00:47:54 +05:30
Torsten Grote
45e7d23bbe
Merge pull request #777 from grote/readme-update
Update README and add funding to About screen
2024-10-14 15:22:26 -03:00
Torsten Grote
001c5f1a17
Update About with NGI0 Entrust Fund 2024-10-14 10:09:36 -03:00
Torsten Grote
7158a9b070
Update README 2024-10-14 10:01:38 -03:00
Torsten Grote
a4ff8946dd
Merge pull request #775 from theimpulson/deprecation
UsbIntentReceiver: Specify parcel's type in method as well
2024-10-14 09:22:18 -03:00
Aayush Gupta
f21e0f8d39 UsbIntentReceiver: Specify parcel's type in method as well
The current method has been deprecated

Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
2024-10-13 12:34:37 +05:30
Torsten Grote
5365ef3a5e
Merge pull request #750 from grote/app-backup-v2
App backup format v2 with compression and deduplication
2024-10-10 17:29:58 -03:00
Torsten Grote
2d47aa3d9f
don't crash in BackupMonitor when there is no packageName
this can happens when it tells us that restore has finished overall
2024-10-10 13:42:24 -03:00
Torsten Grote
16c00be124
remove corrupted snapshots when pruning
before a corrupted snapshot would DoS pruning
2024-10-10 13:42:24 -03:00
Torsten Grote
9339f9f0fb
when cached snapshot is corrupted fall back to loading from backend 2024-10-10 13:42:24 -03:00
Torsten Grote
14775b5c3e
Check that exceptions from file loading get caught
a sha256sum mismatch for example can happen, so the exception should get caught e.g. in RestoreCoordinatorState and should not necessarily be fatal
2024-10-10 13:42:23 -03:00
Torsten Grote
9422d0d309
Encode icons in PNG, because JPEG doesn't support transparency
This caused black squares around icons.
2024-10-10 13:42:23 -03:00
Torsten Grote
682afa1c69
Try to recover data for force stopped apps from latest snapshot
The system doesn't allow us to backup forced stopped apps, but if we had data for them once, we can at least carry it along.
2024-10-10 13:42:23 -03:00
Torsten Grote
c09ea7c075
Use BackupManagerMonitor to handle K/V with no data changed
The fake package manager package is essential for the backup, but when its data doesn't change and we request a normal incremental backup, it doesn't get included, because our transport doesn't even get called for it. Only the BackupMonitor gets a hint that it had no (new?) data via LOG_EVENT_ID_NO_DATA_TO_SEND.
This behavior started with Android 15 that fixed a bug that caused @pm@ to always backup. However, other K/V apps were probably affected before.
2024-10-10 13:42:23 -03:00
Torsten Grote
f8451586df
Minor improvements for app restore
* activity now can be launched from notification
* better logging
* app data restore continues even after activity died
2024-10-10 13:42:23 -03:00
Torsten Grote
11270ff694
Reset latest snapshot to avoid it getting stale
When switching to new storage that doesn't yet have any snapshots, we would otherwise keep the old latest snapshot around.
2024-10-10 13:42:22 -03:00
Torsten Grote
7696b88a5a
Improve RestoreSet display
when user is asked to choose a backup to restore
2024-10-10 13:42:22 -03:00
Torsten Grote
84dc13d267
Split up success and error notification
Now, we don't do partial backups anymore. A snapshot is only done at the end and no information can make it to the backup before. Hence the old error notification with number of apps backed up didn't make sense anymore.
2024-10-10 13:42:22 -03:00
Torsten Grote
b7b07d0ba1
Fix recovery code keyboard input for Android 15
We need to account for IME insets when applying padding to the window.
2024-10-10 13:42:22 -03:00
Torsten Grote
f7354a3d79
Show when launchable system apps do not allow backup
Even though we use d2d, backup is only forced for user apps.
2024-10-10 13:42:22 -03:00
Torsten Grote
751504c214
improve local metadata handling 2024-10-10 13:42:21 -03:00
Torsten Grote
eea65d4082
do scheduling migration before strict mode
otherwise all LoggingFactory ClassLoader lookups that cause disk reads are logged when koin initializes classes
2024-10-10 13:42:21 -03:00
Torsten Grote
b4c84272ff
Update UI state for some system apps if they have NO_DATA
Instead of showing 'Waiting to be backed up...'
2024-10-10 13:42:21 -03:00
Torsten Grote
8d949e2d64
Support adb shell bmgr backupnow
We don't get notified about the start nor the end of such a backup run, so we need hacks to do initialization and finalization.
2024-10-10 13:42:21 -03:00
Torsten Grote
e602bbe2ab
Adapt reuse backup screen after designer input 2024-10-10 13:42:21 -03:00
Torsten Grote
7b0e02c451
Clean up code after refactorings 2024-10-10 13:42:20 -03:00
Torsten Grote
5c75574f65
Use cached snapshots for auto-restore to save time
All snapshots we wrote out should be cached locally. Auto-restore is holding up app installs, so we should be as fast as possible.
2024-10-10 13:42:20 -03:00
Torsten Grote
1e5a4deedf
Clean up libraries, move to where they are included 2024-10-10 13:42:20 -03:00
Torsten Grote
1aa5c68d0a
Add RestoreV1IntegrationTest to ensure we can still restore v1 backup 2024-10-10 13:42:20 -03:00
Torsten Grote
83fd0ba5d1
Upgrade all the binary dependencies we include
Since this is for Android 15 and the new v2 format, this is a good time for upgrading, because we need to test the app extensively anyway.
2024-10-10 13:42:19 -03:00
Torsten Grote
03d2946c93
Remove setting for unlimited quota
we set a hard limit for 1 GiB per app for now, but leave code in to make it configurable in the future
2024-10-10 13:42:19 -03:00
Torsten Grote
176a703720
Offer option to recycle backup after restoring
The most common restore scenario is assumed to be moving from one device to another, like when the old one was lost or stolen. Most users probably don't continue to use the old device themselves still.
Since they just restored this backup on their phone, most data is already in this backup. Deduplication allows re-using that, so it doesn't need to be saved again.
2024-10-10 13:42:19 -03:00
Torsten Grote
20ea0b332d
Delete repo and exit process when key changes
There is no easy way to re-initialize all data based on the old key, so to prevent usage of the old key we need to exit our process. When the app is started again, only the new key will be used.
2024-10-10 13:42:19 -03:00
Torsten Grote
62991ed38b
Move app backup to expert settings 2024-10-10 13:42:19 -03:00
Torsten Grote
9de1d2472b
Remove D2D setting, it is now always on 2024-10-10 13:42:18 -03:00
Torsten Grote
fe8d458890
Always use SnapshotManager to load snapshots to benefit from cache 2024-10-10 13:42:18 -03:00
Torsten Grote
a1baa6f9d2
Implement pruning of old snapshots and unused blobs
This happens regularly after each successful backup.
2024-10-10 13:42:18 -03:00
Torsten Grote
307ccf57de
Move new classes to repo package
as they all relate to interacting with the backup repository
2024-10-08 19:38:15 -03:00
Torsten Grote
32e116ffe1
Polish AppBackupManager and write tests 2024-10-08 19:38:14 -03:00
Torsten Grote
7702fb7bd8
Polish SnapshotCreator and write tests 2024-10-08 19:38:14 -03:00
Torsten Grote
463fc33230
Log memory and when system calls App#onTrimMemory() 2024-10-08 19:38:14 -03:00
Torsten Grote
f188230269
Add padding to all blobs using the Padmé algorithm 2024-10-08 19:38:14 -03:00
Torsten Grote
52f528dbf0
Fully implement BackupReceiver and write tests 2024-10-08 19:38:14 -03:00
Torsten Grote
538d794d8d
Don't uninstall the app and clear data after instrumentation tests 2024-10-08 19:38:14 -03:00
Torsten Grote
dd5180f3b7
Polish BlobCreator and extend its test 2024-10-08 19:38:13 -03:00
Torsten Grote
237fd683bd
Clean up metadata as it lost most of its importance
Historically, metadata was uploaded to the backend after each app update and contained all essential data that is now in snapshots. We still support reading metadata for legacy backups and use the metadata classes as a common wrapper for snapshots. However, there is no need anymore to write out complete historic metadata and maintain duplicated unused information there. This got removed. THe information we do still save and write out is only for UI representation of backup state.

The time of last backup is now managed by SettingsManager.
2024-10-08 19:38:13 -03:00
Torsten Grote
a268116e06
Remove warnings when choosing backup location in UI 2024-10-08 19:36:05 -03:00
Torsten Grote
bfa17fa5ec
Fully implement SnapshotManager
which manages interactions with snapshots, such as loading, saving and removing them.
It also keeps a reference to the latestSnapshot that holds important re-usable data.
2024-10-08 19:36:05 -03:00
Torsten Grote
952cdec55d
Fully implement BlobCache
This class is responsible for caching blobs during a backup run,
so we can know that a blob for the given chunk ID already exists
and does not need to be uploaded again.

It builds up its cache from snapshots available on the backend
and from the persistent cache that includes blobs that could not be added to a snapshot,
because the backup was aborted.
2024-10-08 19:36:05 -03:00
Torsten Grote
5b567c79a2
Also snapshot unchanged APKs 2024-10-08 19:36:05 -03:00
Torsten Grote
cacea886b0
Simplify transport init and token handling
The token used to be very important, because it was our restore set folder name. Now it is just a number in a snapshot, so things get a bit simpler.
2024-10-08 19:36:05 -03:00
Torsten Grote
3c4b4f705c
Remove hack of @pm@ backup when initializing transport
as it isn't needed anymore with v2 since we don't do duplicate restore sets anymore
2024-10-08 19:36:04 -03:00
Torsten Grote
7f9e84fdb6
Stop writing out old metadata to backend
We'll probably keep metadata around for internal information about backup state
2024-10-08 19:36:04 -03:00
Torsten Grote
c2ad309f93
K/V backup and restore using v2
while maintaining support for v0 and v1
2024-10-08 19:36:04 -03:00
Torsten Grote
7c7ea5fcd7
Full backup and restore using v2
while maintaining support for v0 and v1
2024-10-08 19:36:04 -03:00
Torsten Grote
83708d9403
Prepare restore backup loading for v2 2024-10-08 19:36:03 -03:00
Torsten Grote
8ce79f4195
Add protobuf-kotlin-lite and use new builders 2024-10-08 19:36:03 -03:00
Torsten Grote
897ae48b44
Back up app APKs in new v2 format
We still support restoring in v1 format for some time.
2024-10-08 19:36:03 -03:00
Torsten Grote
e17c98857f
Back up app icons in new v2 format
We still support downloading in v1 format for some time.
2024-10-08 19:36:03 -03:00
Torsten Grote
1efa8e8f59
Add prototype plumbing for new v2 app backup 2024-10-08 19:36:03 -03:00
Torsten Grote
e6905c0365
Move tink library into core module and expose via CoreCrypto
This also moves key derivation via HKDF into the core.
2024-10-08 19:36:03 -03:00
Torsten Grote
c19787a7fa
Prepare backends for new app backup repository 2024-10-08 19:36:02 -03:00
Torsten Grote
d2df088f2c
Add zstd-jni library 2024-10-08 19:36:02 -03:00
Torsten Grote
cb68f75eb6
remove kotlin protobuf as its not in aosp 2024-10-08 19:36:02 -03:00
Torsten Grote
b2307d94dd
Add protobuf definitions for snapshot 2024-10-08 19:36:02 -03:00
Torsten Grote
75797f93e7
add readme for app dedup research 2024-10-08 19:36:02 -03:00
Torsten Grote
0ae1f0ce7d
fix broken link in files backup docs 2024-10-08 19:36:01 -03:00
Torsten Grote
a9df9a2d2f
Merge pull request #771 from grote/770-backup-start
Unify code to start new backup
2024-10-08 18:21:15 -03:00
Torsten Grote
d6572979cc
Unify code to start new backup
to ensure that files backup and app backup will always run if they should
2024-10-08 16:13:12 -03:00
Torsten Grote
5498e838db
Merge pull request #764 from grote/697-receivery-code-crash
Trim white-spaces from recovery code words
2024-10-07 11:09:26 -03:00
Torsten Grote
4bad79a924
Merge pull request #772 from grote/769-tiktok
Also show TikTok in Backup status
2024-10-07 11:09:03 -03:00
Torsten Grote
3601494b06
Also show TikTok in Backup status
The apps ships an instrumentation configuration which we've so far only soon for instrumentation test dev apps. Now, we do more checks to identify those.
2024-10-07 10:47:27 -03:00
Torsten Grote
5f8e85944a
Merge pull request #767 from t-m-w/fix-title-of-restore-notification-channel
Fix title of restore notification channel
2024-10-04 09:30:09 -03:00
t-m-w
a27ef47294
Fix title of restore notification channel
The restore foreground service notification uses the restore channel, which was inadvertently using the title from the error channel, showing "Auto restore flash drive error" when tapping and holding on the notification, and showing that channel name twice in the notification settings.
2024-10-03 16:09:25 -04:00
Torsten Grote
542a79e2e1
Trim white-spaces from recovery code words 2024-10-03 14:09:39 -03:00
Torsten Grote
f2aec3f932
Merge pull request #747 from theimpulson/a15
Support edge to edge
2024-09-20 14:03:29 -03:00
Torsten Grote
cf7953edf7
Merge pull request #734 from grote/unified-backends
Unify Storage Backends
2024-09-19 13:52:34 -03:00
Aayush Gupta
b9b7c96063 Support edge to edge
Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
2024-09-18 20:21:09 +05:30
Torsten Grote
78ef0caea7
clean up libs and fix AOSP build 2024-09-12 09:34:00 -03:00
Torsten Grote
206affee00
Move AOSP libs to root libs dir 2024-09-12 09:33:59 -03:00
Torsten Grote
b59da2a805
Ensure ChunkWriter uses current backend
When changing backends, the ChunkWriter could still use the old one causing data loss, because chunks assumed to exist on new backend, were written to old one.
2024-09-12 09:33:59 -03:00
Torsten Grote
c83e8f392e
Fix issue with DocumentFileCache 2024-09-12 09:33:59 -03:00
Torsten Grote
96a3564610
Switch everything to new backends 2024-09-12 09:33:58 -03:00
Torsten Grote
58d58415c5
Use new Backend directly in storage lib 2024-09-12 09:18:22 -03:00
Torsten Grote
0c1dfb316d
Use new Backend directly in the app 2024-09-12 09:18:22 -03:00
Torsten Grote
5bb599e528
Use new SafBackend in DocumentsProviderStoragePlugin 2024-09-12 09:18:21 -03:00
Torsten Grote
8c05ccc39d
Use new WebDavBackend in WebDavStoragePlugin 2024-09-12 09:18:21 -03:00
Torsten Grote
099e0ba6d5
Remove hasData() method from StoragePlugin
because it is one extra request for packages that do have data and from the looks of it not really needed.
2024-09-12 09:18:21 -03:00
Torsten Grote
27eb95f768
Split key concern out of storage plugin
This creates a KeyManager interface in the new core module which the storage module can use to get the key from.
2024-09-12 09:18:21 -03:00
Torsten Grote
9e56384cb2
Add core gradle module with unified storage backends 2024-09-12 09:18:21 -03:00
Torsten Grote
fa56a74ad7
Merge pull request #742 from theimpulson/a15
Android 15 updates
2024-09-12 09:17:31 -03:00
Aayush Gupta
bc2cb257b1 app: test: Force robolectric to SDK 34 for now
Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
2024-09-12 17:31:01 +05:30
Aayush Gupta
4a235c6739 app: test: Assert applicationInfo is non-null
Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
2024-09-10 12:13:21 +05:30
Aayush Gupta
217fd97d3e Bump target and compile SDK to API 35
Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
2024-09-10 12:13:15 +05:30
Aayush Gupta
a334eb0e91 Update AGP, Gradle and dependencies to AOSP versions
* Also regenerate JARs against Android 15 user build

Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
2024-09-09 11:39:58 +05:30
Torsten Grote
9461e18692
Merge pull request #740 from seedvault-app/cd/android15-version
Bump version to 15-4.1
2024-09-06 12:47:04 -03:00
Chirayu Desai
bf609f9723 Bump version to 15-4.1, mention 15 in README
* VanillaIceCream

Change-Id: Idd149e2be3329452ab61941cde2ff4f2ae3575ca
2024-09-06 20:52:49 +05:30
Torsten Grote
10f9f8e840
Merge pull request #729 from theimpulson/material3fixes
Fixes for Material3
2024-09-06 08:41:00 -03:00
Aayush Gupta
085d152e55 drawable: Use text color for system icons
Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
2024-09-06 12:50:42 +05:30
Torsten Grote
ff59decaab
Merge pull request #731 from lucasmz-dev/android14-bump-version
Bump version
2024-09-05 16:24:37 -03:00
Torsten Grote
dc9391deef
Merge pull request #723 from grote/allow-restore
Allow restore whenever the user feels like it
2024-09-05 16:24:13 -03:00
Torsten Grote
b8602fdcc2
Merge pull request #736 from grote/fix-retry
Fix retries: don't upload metadata three times
2024-09-05 16:14:20 -03:00
Torsten Grote
710354d6d0
Merge pull request #722 from grote/restore-foreground-service
Start a foreground service during restore
2024-09-05 16:14:02 -03:00
Torsten Grote
0a7ce66bcf
Merge pull request #733 from grote/install-fixes
Two small fixes for app restore
2024-09-05 09:27:00 -03:00
Torsten Grote
17d0885e77
Fix retries: don't upload metadata three times 2024-09-05 09:11:52 -03:00
Torsten Grote
40d0f55012
Show app is in progress before we download APKs 2024-08-28 15:07:36 -03:00
Torsten Grote
7214d9c666
Don't allow app selection toggles before icons have loaded 2024-08-28 15:07:31 -03:00
LucasMZ
006dfadca0
Bump to 14-4.1 - many cool things :D 2024-08-23 22:40:40 -03:00
Torsten Grote
d266c36c91
Don't use Context#startForegroundService() because we may get killed
If the foreground service doesn't have anything to do and terminates quickly, the system will kill us, even though the service had called startForeground(). To prevent this, we don't promise that our service will be a foreground service. We can still be a foreground service, but escape the punishment if we are too quick.
2024-08-22 17:45:39 -03:00
Torsten Grote
5418a8ef12
Merge pull request #721 from grote/dont-restore-existing-files
Don't restore files that still exist unchanged
2024-08-22 17:39:55 -03:00
Torsten Grote
418dfb344c
Fix joining string for file selection 2024-08-22 10:25:05 -03:00
Torsten Grote
a2189bc1f7
Restore files ownership only when file isn't pending anymore
because the system doesn't allow us to open files that we don't own
2024-08-22 09:35:40 -03:00
Torsten Grote
3683f82363
make file restore numbers add up by showing duplicates and errors 2024-08-22 09:35:40 -03:00
Torsten Grote
f51c758493
don't restore files that still exist unchanged
(same size and lastModified)
2024-08-22 09:35:39 -03:00
Torsten Grote
dc92e41aa8
declare foreground service type also when starting service 2024-08-22 09:35:39 -03:00
Torsten Grote
ff3956d9c4
store owner of media file and whether it is marked favorite 2024-08-22 09:35:39 -03:00
Torsten Grote
639947b87e
Start a foreground service during restore
so the system won't kill us, even if the user navigates away.
2024-08-21 17:28:37 -03:00
Torsten Grote
bebb9005da
Merge pull request #719 from grote/only-install-if-not-installed
Don't re-install apps that are already installed and disable auto-restore
2024-08-21 17:22:41 -03:00
Torsten Grote
5b085b6518
Merge pull request #725 from grote/usb-respect-backup-setting
Don't back up to USB, if backup disabled
2024-08-21 17:06:44 -03:00
Torsten Grote
61e748ac42
Don't back up to USB, if backup disabled 2024-08-21 14:47:54 -03:00
Torsten Grote
ebb662add7
Merge pull request #720 from grote/fix-app-selection
Fix app selection when restoring after SUW
2024-08-21 14:36:26 -03:00
Torsten Grote
99232862ca
Merge pull request #717 from grote/ask-if-restore
Ask on first run if user wants restore
2024-08-21 14:24:56 -03:00
Torsten Grote
1b9dc25896
Allow restore whenever the user feels like it 2024-08-20 17:53:24 -03:00
Torsten Grote
570850aa51
Disable auto-restore during install, if it was on 2024-08-16 10:53:00 -03:00
Torsten Grote
09074c5dff
Move Settings.Secure backup flags into BackupStateManager 2024-08-16 10:53:00 -03:00
Torsten Grote
3397fdbd87
Fix app selection when restoring after SUW 2024-08-16 09:45:46 -03:00
Torsten Grote
109e0ae281
Don't re-install apps that are already installed 2024-08-16 09:29:43 -03:00
Torsten Grote
7f934c8209
Fix back navigation when FirstRunFragment is shown 2024-08-15 18:29:38 -03:00
Torsten Grote
22b3ace3aa
Ask on first run if user wants restore 2024-08-15 18:29:37 -03:00
Torsten Grote
cff5d20342
Merge pull request #712 from grote/debug-launcher
Add launcher icon for debug builds
2024-08-15 18:28:25 -03:00
Torsten Grote
27cda5eba4
Merge pull request #718 from grote/non-suw-restore-uncheck
Uncheck system apps by default if restore outside of SUW
2024-08-15 18:04:23 -03:00
Torsten Grote
e4de9e1c41
Uncheck system apps by default if restore outside of SUW 2024-08-15 15:46:40 -03:00
Torsten Grote
e4a61c1f7a
Add Android Studio run configuration 2024-08-15 10:11:10 -03:00
Torsten Grote
e6e6154b7d
Add launcher icon for debug builds 2024-08-15 09:56:19 -03:00
Torsten Grote
b571da787a
Merge pull request #705 from grote/565-choose-files-restore
Allow choosing what files/folders will get restored
2024-08-15 09:42:54 -03:00
Torsten Grote
0a10db3bba
split out FilesItem class into own file 2024-08-02 13:54:44 -03:00
Torsten Grote
66836c875c
Fixes for MD3 that got merged in the meantime 2024-07-31 15:09:44 -03:00
Torsten Grote
777aa6d525
don't create empty snapshots 2024-07-31 15:09:43 -03:00
Torsten Grote
431e5ba8f5
toggle files checkbox when clicking them and add more space before checkbox 2024-07-31 15:09:43 -03:00
Torsten Grote
118b2c0be0
Integrate files selection into real Seedvault app 2024-07-31 15:09:43 -03:00
Torsten Grote
dbb40a4a5b
Only attempt to do a manual app backup, if it is actually enabled 2024-07-31 15:09:43 -03:00
Torsten Grote
7d6ab6f8e0
Make demo restore with file selection functional
This injects FileSelectionManager as a singleton, so we can use its selection to recreate a snapshot, even in a service.

Also includes some UI improvements.
2024-07-31 15:09:43 -03:00
Torsten Grote
5012099419
Add UI prototype for selecting file to storage demo app 2024-07-31 15:09:43 -03:00
Torsten Grote
2b07b8417c
Add FileSelectionManager to storage lib
This new manager will be responsible for handling file selection by user prior to restore.
2024-07-31 15:09:42 -03:00
Torsten Grote
adbc412d20
Merge pull request #709 from theimpulson/gradle
Bump AGP, Gradle and dependencies to latest stable release
2024-07-31 14:59:09 -03:00
Torsten Grote
2741db3a67
Upgrade coroutines to 1.7.3 to fix lint task 2024-07-31 14:44:07 -03:00
Torsten Grote
4f341d177c
Merge pull request #710 from seedvault-app/t-m-w-patch-1
Fix AOSP build
2024-07-31 14:38:55 -03:00
t-m-w
a00ee0fa4f
Fix AOSP build 2024-07-31 11:02:33 -04:00
Torsten Grote
e7999db83f
Merge pull request #708 from theimpulson/material3
fragment_backup_content: Don't set custom style on FAB
2024-07-31 11:49:15 -03:00
Aayush Gupta
ce2b9c15f1 Bump AGP, Gradle and dependencies to latest stable release
dependencies are QPR3

Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
2024-07-27 13:06:19 +07:00
Aayush Gupta
955f38fb44 fragment_backup_content: Don't set custom style on FAB
Conflicts with dynamic theme

Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
2024-07-27 11:25:55 +07:00
Torsten Grote
a07ab64469
Merge pull request #699 from theimpulson/material3
Material3
2024-07-26 15:06:24 -03:00
Aayush Gupta
2f96393a89 Apply dynamic colors to all acitvites
Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
2024-07-26 15:53:10 +07:00
Aayush Gupta
3f7022ecb7 fragment_restore_app_selection: Set background color to squashed layout
CollapsingToolbarLayout doesn't seems to be respecting background color for some reason

Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
2024-07-11 16:57:06 +07:00
Aayush Gupta
70413f1425 drawable: Tint colors directly instead of relying on system theme
Material theme seems to be not respecting the tint color in the XML.
Override the colors manually to get the job done.

Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
2024-07-11 16:39:52 +07:00
Torsten Grote
07116b4f4c Use MD3 switches for files backup config 2024-07-11 15:59:03 +07:00
Torsten Grote
0dcab41fd1 Use MD3 switches in settings 2024-07-11 15:59:03 +07:00
Aayush Gupta
98c6ebab8d SchedulingFragment: Implement Material3 based ListPreference
Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
2024-07-11 15:59:03 +07:00
Aayush Gupta
d15fe36638 RecoveryCodeInputFragment: Switch to MaterialAutoCompleteTextView
Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
2024-07-11 15:59:02 +07:00
Aayush Gupta
cdcb862d9d Migrate to MaterialAlertDialog everywhere
Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
2024-07-11 15:59:02 +07:00
Aayush Gupta
033498aa17 themes: Switch to Material3 theme
* Merge accent and primary color for simpler color management
* Apply background color on status and navigation bar
* Drop non-required colors

Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
2024-07-11 15:59:02 +07:00
Aayush Gupta
412ed9ee16 themes: Switch to single theme for all activities
Default to NoActionBar theme and use toolbar where required

Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
2024-07-11 15:59:02 +07:00
Torsten Grote
12fb4d13d4
Merge pull request #686 from seedvault-app/cde/macos-12
Use macOS 12 for test workflows, 11 will soon be deprecated
2024-07-10 14:12:59 -03:00
Torsten Grote
b07bb6bc48
Merge pull request #692 from grote/679-consider-other-transports
Better scheduling co-existence with other transport
2024-07-08 15:32:24 -03:00
Torsten Grote
1543dccd96
Merge pull request #702 from grote/693-webdav-pipe-closed
Improve logging relevant for WebDAV streams
2024-07-01 17:43:10 -03:00
Torsten Grote
490c7882e4
Add missing docs for sendBackupData() 2024-06-27 17:20:06 -03:00
Torsten Grote
7afd496db9
Catch the underlying exception when WebDAV writing fails due to closed pipe 2024-06-27 17:20:05 -03:00
Torsten Grote
823eb4ffab
Improve logging relevant for WebDAV streams 2024-06-27 16:34:37 -03:00
Torsten Grote
d5717496d7
Merge pull request #700 from grote/okhttp4.12
Upgrade dav4jvm library
2024-06-24 17:59:47 -03:00
Torsten Grote
a1f6be0447
Remove dav4jvm InputStream hack as not needed with latest version 2024-06-24 13:53:08 -03:00
Torsten Grote
6e84d727c2
Update dav4jvm to b8be778
as recommended by upstream: https://github.com/bitfireAT/dav4jvm/discussions/36#discussioncomment-9862613
2024-06-24 13:48:40 -03:00
Torsten Grote
520074521e
Update okhttp to 4.12.0 2024-06-24 13:09:49 -03:00
Torsten Grote
cba160bc8f
Merge pull request #689 from grote/687-restore-provider-kill
Don't try to restore storage providing app
2024-06-24 11:03:11 -03:00
Chirayu Desai
6132884c11 Use macOS 12 for test workflows, 11 will soon be deprecated
More info: https://github.blog/changelog/2024-05-20-actions-upcoming-changes-to-github-hosted-macos-runners/

Change-Id: I7dc2a854d2cd19d776db40c5d01016b98760d487
2024-06-19 23:49:04 +05:30
Torsten Grote
484767bf16
Disable framework scheduling when scheduling backup, because another transport may have re-enabled it 2024-06-19 09:29:22 -03:00
Torsten Grote
878492088d
Don't disable framework scheduling when not current transport 2024-06-19 09:29:22 -03:00
Torsten Grote
97093ca0b2
Don't restore the storage provider app
otherwise it gets killed during data restore which kills our restore process
2024-06-19 09:24:01 -03:00
Torsten Grote
22ca2550c2
Merge pull request #670 from grote/309-restore-choose-apps
Allow choosing which apps will get restored
2024-06-19 09:21:59 -03:00
Torsten Grote
fd5089d0ad
Merge pull request #681 from grote/webdav-trailing-slash
Improve WebDAV compatibility
2024-06-18 10:55:14 -03:00
Torsten Grote
f15018253c
Prevent NoClassDefFound error when a WebDAV server returns GetLastModified
which happens in the case of dufs (see last commit)
2024-06-14 09:17:52 -03:00
Torsten Grote
4ac02018fa
Fix uncaught throwable with dufs WebDAV server
The underlying issue will affect other functionality though: https://github.com/sigoden/dufs/issues/400
2024-06-14 09:17:52 -03:00
Torsten Grote
56e26083fc
Fix PROPFIND fallback for lighttpd as well 2024-06-14 09:17:51 -03:00
Torsten Grote
1dd898b068
Add fallback when WebDAV PROPFIND with depth=2 isn't supported 2024-06-14 09:17:51 -03:00
Torsten Grote
c522c460fd
Add trailing slash to WebDAV collection requests 2024-06-14 09:17:50 -03:00
Torsten Grote
b223af6413
Merge pull request #680 from bernhardreiter/patch-1
docs: (minor) Fix typo README.md
2024-06-13 09:03:26 -03:00
Bernhard E. Reiter
c2224df57a
docs: (minor) Fix typo README.md 2024-06-13 11:10:22 +02:00
Aayush Gupta
1b7686de08
Merge pull request #677 from grote/webdav-timeouts
Increase WebDAV timeouts and declare body one-shot
2024-06-12 19:52:35 +05:30
Torsten Grote
c483332b15
Try to fix issue where our transport doesn't get registered in emulator 2024-06-12 09:57:24 -03:00
Steve Soltys
08727651af
Skip magic package manager in assertions
We still don't know why, but after latest test fixes, the @pm@ package didn't have the the @meta@ key in the backup, but it did in restore.
2024-06-07 09:35:15 -03:00
Torsten Grote
e76ab1ca43
Increase WebDAV timeouts and declare body one-shot
As most output streams come from the system, we can't re-send them. So when okhttp wants to retry it tries to write to closed streams which will fail. We declare our outputstream writing as one-shot for this reason.
2024-06-05 12:40:42 -03:00
Torsten Grote
0e224b1238
Filter out @end@ helper package
it doesn't really exist and should probably not even be in the backup metadata. It messes up progress reporting, if we keep it in.
2024-05-31 17:11:34 -03:00
Torsten Grote
fa19261d8e
Improve app data restore process
Apps are now restored alphabetically to be consistent with the other lists. Some irrelevant apps are hidden. Under the hood, we now use an AsyncListDiffer like in the other lists.
2024-05-31 17:06:14 -03:00
Torsten Grote
b3f93adf77
Factor out code into new
AppDataRestoreManager

which was in RestoreViewModel before.
Now all three steps of app restore have their own dedicated manager class making the ViewModel more readable.
2024-05-31 15:07:35 -03:00
Torsten Grote
66f3852edf
Delete cached icons after restore is done 2024-05-31 13:35:55 -03:00
Torsten Grote
ebf68cfe73
Don't try to install system apps without APK
during restore process. These can usually not be manually installed anyway and just clutter the list making it harder for the user to find their important apps and potential failures there.
2024-05-31 12:16:01 -03:00
Torsten Grote
f408381d18
Fix backup/restore instrumentation tests 2024-05-31 11:50:59 -03:00
Torsten Grote
88619b94c1
Fix red error color
Resources$NotFoundException: Resource ID #0x7f060258 type #0x2 is not valid
2024-05-31 11:50:59 -03:00
Torsten Grote
f68fa0f3fc
Fix AOSP build 2024-05-31 11:50:59 -03:00
Torsten Grote
4b1c76d585
don't record excluded apps in backup 2024-05-31 11:50:59 -03:00
Torsten Grote
e54d96d548
Re-factor and improve ApkRestore 2024-05-31 11:50:59 -03:00
Torsten Grote
05c39e98fa
Add tests for AppSelectionManager 2024-05-31 11:50:58 -03:00
Torsten Grote
6143ec04ed
Upgrade Roboeletric and bump minSdk to 34 2024-05-31 11:50:58 -03:00
Torsten Grote
9cc72bfa38
Show size for (all combined) system apps when restoring 2024-05-31 11:50:58 -03:00
Torsten Grote
f5fb9ffffa
Factor out app restore selection code into new AppSelectionManager 2024-05-31 11:50:58 -03:00
Torsten Grote
332387fd58
Encrypt zip file with icons
While we still don't guarantee that an attacker with access to the storage can't find out which apps we use (APKs are still unencrypted after all), we go into this direction.

Also, this should make it impossible for an attacker that can modify files to replace or otherwise mess with the icons.
2024-05-31 11:10:12 -03:00
Torsten Grote
eecfcdb285
Improve icon display when selecting apps for restore 2024-05-31 11:10:12 -03:00
Torsten Grote
787b9346a8
Add meta item for restoring all (internal) system apps
This way we don't need to show the long complicated list, but provide an all or nothing option at least.
2024-05-31 11:10:11 -03:00
Torsten Grote
573e48f393
Sort app selection like backup status and show sections
system data comes first and then apps
2024-05-31 11:10:11 -03:00
Torsten Grote
af1b3de9cb
Fix icon colors (again!)
see 5662409ef5
2024-05-31 11:10:11 -03:00
Torsten Grote
a447895079
Cleaned up backup status list by separating system data and apps 2024-05-31 11:10:11 -03:00
Torsten Grote
1ac613f588
Also store icons of launchable system apps 2024-05-31 11:10:11 -03:00
Torsten Grote
a0a3e871e0
Show actual app name in app selection for restore 2024-05-31 11:10:11 -03:00
Torsten Grote
1667d44967
Sort apps that failed to install by name 2024-05-31 11:10:10 -03:00
Torsten Grote
56d8d64261
Store app name and whether it is a launchable system app in metadata
this is helpful for restore, so the user can see app names when deciding which apps to restore
2024-05-31 11:10:10 -03:00
Torsten Grote
5a2f1187a8
Store app icons in separate file
so they can be shown when selecting apps for restore which is before we have downloaded the APK files to extract icons from
2024-05-31 11:10:10 -03:00
Torsten Grote
905340770c
Allow user to choose which apps should get restored 2024-05-31 11:10:10 -03:00
Torsten Grote
4803288629
Show other (launchable) system apps in backup status 2024-05-31 11:10:10 -03:00
Torsten Grote
16813395c7
Change app excludes from switches to checkboxes
apparently this is closer to the material design specs:
https://m2.material.io/components/checkboxes#usage
2024-05-31 11:10:10 -03:00
Torsten Grote
af15b4afdf
Merge pull request #669 from theimpulson/gradleUpdates
Misc Gradle updates
2024-05-31 11:09:37 -03:00
Aayush Gupta
d1660990ba github: workflows: Validate Gradle wrapper before building
Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
2024-05-31 10:24:30 +05:30
Aayush Gupta
b1909025c0 gradle: Migrate from kapt to ksp
Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
2024-05-30 12:20:20 +05:30
Aayush Gupta
09c9132ff0 gradle: Drop non-required buildscript blocks
Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
2024-05-30 12:07:51 +05:30
Aayush Gupta
6953f154b3 gradle: Migrate to recommended method of build version catalogs
This fixes broken AGP Upgrade Assistant in Android Studio as well as detects
the version catalog files in Android view.

Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
2024-05-30 12:07:51 +05:30
Aayush Gupta
18c85a76c7 gradle: Bump to latest AGP and Gradle version
Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
2024-05-30 11:44:42 +05:30
Torsten Grote
d9642aec9d
Fix InstallRestriction
We had a logic bug where isAllowed actually meant isDisallowed
2024-05-28 14:33:28 -03:00
Torsten Grote
5184020f2f
Merge pull request #666 from chirayudesai/78-fixup
fixup! restore: Skip installing APKs if not allowed by policy
2024-05-23 10:05:55 -03:00
Chirayu Desai
0a81c42fd1 fixup! restore: Skip installing APKs if not allowed by policy
Change-Id: Iaa1590df84e3d1785baf0f938da0a2b2fe43ccd0
2024-05-23 16:06:44 +05:30
Torsten Grote
8b4caec272
Use absolute link to FAQ in README.md (#660)
* Use absolute link to FAQ in README.md

Fixes #533
2024-05-23 15:56:10 +05:30
Michael Bestas
1653e6d302 Make Seedvault almost REUSE compliant 2024-05-23 00:44:51 +05:30
Michael Bestas
ecf3b99ac2 misc: Add SPDX copyright headers 2024-05-23 00:44:51 +05:30
Michael Bestas
1baf4b871e app: Add SPDX copyright headers 5/5 2024-05-23 00:44:51 +05:30
Michael Bestas
bfd51350b2 app: Add SPDX copyright headers 4/5 2024-05-23 00:44:51 +05:30
Michael Bestas
a46e93261c app: Add SPDX copyright headers 3/5 2024-05-23 00:44:51 +05:30
Michael Bestas
7f7861aba4 app: Add SPDX copyright headers 2/5 2024-05-23 00:44:51 +05:30
Michael Bestas
c1c2385bd5 app: Add SPDX copyright headers 1/5 2024-05-23 00:44:51 +05:30
Michael Bestas
297f335fa9 Add missing newlines at the end of the files 2024-05-23 00:44:51 +05:30
Hosted Weblate
2bbf46bc4a Import translations from Weblate
Co-authored-by: Ettore Atalan <atalanttore@googlemail.com>
Co-authored-by: Hosted Weblate <hosted@weblate.org>
Co-authored-by: gallegonovato <fran-carro@hotmail.es>
Co-authored-by: lucasmz-dev <git@lucasmz.dev>
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/de/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/es/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/pt/
Translation: CalyxOS/Seedvault
2024-05-23 00:44:39 +05:30
Torsten Grote
54f9e08c71 Fix scheduling for removable drive users 2024-05-23 00:42:47 +05:30
Hosted Weblate
54d9cfcbe7 Import translations from Weblate
Co-authored-by: Fjuro <fjuro@alius.cz>
Co-authored-by: Hosted Weblate <hosted@weblate.org>
Co-authored-by: Igor Sorocean <sorocean.igor@gmail.com>
Co-authored-by: Oğuz Ersen <oguz@ersen.moe>
Co-authored-by: lucasmz <git@lucasmz.dev>
Co-authored-by: lucasmz-dev <git@lucasmz.dev>
Co-authored-by: rehork <cooky@e.email>
Co-authored-by: 大王叫我来巡山 <hamburger2048@users.noreply.hosted.weblate.org>
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/cs/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/pl/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/pt_BR/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/ro/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/tr/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/zh_Hans/
Translation: CalyxOS/Seedvault
2024-05-18 22:48:59 +05:30
Hosted Weblate
684ce8201b Import translations from Weblate
Co-authored-by: Fjuro <fjuro@alius.cz>
Co-authored-by: Hosted Weblate <hosted@weblate.org>
Co-authored-by: Igor Sorocean <sorocean.igor@gmail.com>
Co-authored-by: Kristian Nordin <kristian.po@proton.me>
Co-authored-by: Oğuz Ersen <oguz@ersen.moe>
Co-authored-by: gallegonovato <fran-carro@hotmail.es>
Co-authored-by: ikya91 <weblate.haq9g@simplelogin.com>
Co-authored-by: lucasmz <git@lucasmz.dev>
Co-authored-by: lucasmz-dev <git@lucasmz.dev>
Co-authored-by: rehork <cooky@e.email>
Co-authored-by: 大王叫我来巡山 <hamburger2048@users.noreply.hosted.weblate.org>
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/cs/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/es/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/fr/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/pl/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/pt_BR/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/ro/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/sv/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/tr/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/zh_Hans/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault_contactsbackup/sv/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault_storage/sv/
Translation: CalyxOS/Seedvault
Translation: CalyxOS/Seedvault contacts backup
Translation: CalyxOS/Seedvault storage backup
2024-05-14 22:21:35 +05:30
Torsten Grote
6dfc0583e5
Merge pull request #502 from chirayudesai/78-skipapk
Skip installing APKs if not allowed by policy
2024-05-14 13:35:25 -03:00
Chirayu Desai
422e3f547d restore: Skip installing APKs if not allowed by policy
* We should not bypass the OS-wide APK install restriction.
* Simply treat that as just not having the APK in the first place,
  since we do support that as an option.
* This still lets users install apps via the store it was downloaded
  from, if said store is installed and allowed to install apps.
* Introduce InstallRestriction to make testing easier.

Co-Authored-By: Torsten Grote <t@grobox.de>
Change-Id: Ic0a56961c9078d4dd542db5d9fc75034abb27bea
2024-05-14 20:34:33 +05:30
Torsten Grote
bb562a4cb2 Catch out 507 HTTP error when using WebDAV
Nextcloud has a bug that lets us write chunked transfers over quota:
https://github.com/nextcloud/server/issues/7993

However, when we upload small files, we can get the proper 507 response and thus detect out of space situations and warn the user about them.
2024-05-14 20:31:15 +05:30
Torsten Grote
066b147315 Catch out of space exception during FullBackup 2024-05-14 20:31:15 +05:30
Torsten Grote
860733d238 Don't retry backup on removable storage 2024-05-14 20:31:15 +05:30
Torsten Grote
49262682d1 Don't do backup, if space is already low, warn instead 2024-05-14 20:31:15 +05:30
Torsten Grote
36910fc777 Catch out of space errors and show error notification 2024-05-14 20:31:15 +05:30
Torsten Grote
5cae1b202d Show app restore sets sorted by latest first 2024-05-14 20:31:15 +05:30
Torsten Grote
7ec80d4ebb Store total backup size and show it when restoring
This is done by storing also the APK sizes in addition to the app data size we already store.
2024-05-14 20:31:15 +05:30
Torsten Grote
1d8c438723 Implement a storage plugin method to get free space 2024-05-14 20:31:15 +05:30
Torsten Grote
81cbb6e4dc Get free space for storage authority if not available by other means 2024-05-14 20:31:15 +05:30
Torsten Grote
c04ddfa9a0 Add helper text for WebDAV URL field 2024-05-08 19:10:46 +05:30
Torsten Grote
d0cf168198
Merge pull request #647 from grote/webdav
Implement a native WebDAV plugin
2024-05-06 13:41:45 -03:00
Torsten Grote
1931024a10
Introduce constant for files snapshot file extension 2024-05-03 16:09:41 -03:00
Torsten Grote
2f6edf6b4b
Rename StoragePluginEnum to StoragePluginType 2024-05-03 15:59:28 -03:00
Torsten Grote
4651ad5eb3
Replace field naming _foo with mFoo 2024-05-03 15:57:01 -03:00
Torsten Grote
01dbcf5f2f
Move StorageProperties class into its own file 2024-05-03 15:54:04 -03:00
Torsten Grote
bf40b53863
Merge pull request #652 from grote/scheduling-i18n
Always update next scheduling time in UI
2024-04-29 13:46:06 -03:00
Torsten Grote
b041c208ac
Always update next scheduling time in UI
Also avoid hard-coded strings and log when no backups are scheduled.
2024-04-29 12:00:39 -03:00
Torsten Grote
0b4bd09e7d
Don't assume SAF-based storage is available
it may be WebDAV now
2024-04-25 14:13:32 -03:00
Torsten Grote
0e51c00bca
Properly migrate existing users to new plugin setup 2024-04-25 09:51:46 -03:00
Torsten Grote
a95ba41196
Reset WebDAV config state when the UI is left 2024-04-25 09:51:46 -03:00
Torsten Grote
f4366d930f
Adapt integration test to new plugin structure 2024-04-25 09:51:46 -03:00
Torsten Grote
a4cccabc5e
Don't allow changing backup location while backup is running 2024-04-25 09:51:45 -03:00
Torsten Grote
0e4c37e796
Properly track if a backup is running
this is important, so we don't allow more than one backup running at the same time and not swapping out the storage while one is running.

Previously, we had some bare bones tracking, but nothing precise.
2024-04-25 09:51:45 -03:00
Torsten Grote
b1c87a8a9e
Add the UI for the WebDAV plugin
including ViewModel and StoragePluginManager logic
2024-04-25 09:51:45 -03:00
Torsten Grote
7e612cb8e0
Introduce StoragePluginManager to handle storage plugins
and allow changing them dynamically. So far plugins were injected into the dependency graph and couldn't be changed at runtime, only their config could. Now we have the infrastructure in place to really allow for more than one plugin.
2024-04-25 09:51:45 -03:00
Torsten Grote
2489190824
Rename Storage to SafStorage
in preparation for generalization
2024-04-25 09:51:45 -03:00
Torsten Grote
6788d0d25a
Prepare backup destination UI refactoring
Mostly renaming for clarity.
2024-04-25 09:51:44 -03:00
Torsten Grote
ec8190755e
Add a method for testing if storage works
This is especially useful for WebDAV storage where the user can supply whatever URL and before proceeding, we need to know whether that URL and the provided credentials are actually working.
2024-04-25 09:51:44 -03:00
Torsten Grote
4f2ead66a5
Ensure root folder exists when using storage
We use the same root folder for app and files backup. App backup usually creates the root folder, but if only storage backup is used, it will be missing and needs to be created.
2024-04-25 09:51:44 -03:00
Torsten Grote
e6e65d0dd1
WebDAV files backup plugin 2024-04-25 09:51:44 -03:00
Torsten Grote
870d1617d2
Initial implementation of WebDavStoragePlugin 2024-04-25 09:51:43 -03:00
Torsten Grote
cc8d3079d2
Merge pull request #618 from weblate/weblate-calyxos-seedvault
Translations update from Hosted Weblate
2024-04-24 14:45:43 -03:00
Hosted Weblate
a25ecd1886
Import translations from Weblate
Co-authored-by: Anonymous <noreply@weblate.org>
Co-authored-by: Fjuro <fjuro@alius.cz>
Co-authored-by: Fjuro <ifjuro@proton.me>
Co-authored-by: Hosted Weblate <hosted@weblate.org>
Co-authored-by: Igor Sorocean <sorocean.igor@gmail.com>
Co-authored-by: Kristian Nordin <kristian.po@proton.me>
Co-authored-by: Michael Bestas <mkbestas@gmail.com>
Co-authored-by: Oğuz Ersen <oguz@ersen.moe>
Co-authored-by: Suguru Hirahara <shirahara@users.noreply.hosted.weblate.org>
Co-authored-by: Yaron Shahrabani <sh.yaron@gmail.com>
Co-authored-by: Yuya <yuyaj@tutanota.com>
Co-authored-by: ZehRique <zehrique.dev@gmail.com>
Co-authored-by: gallegonovato <fran-carro@hotmail.es>
Co-authored-by: lucasmz <git@lucasmz.dev>
Co-authored-by: lucasmz <github@lucasmz.dev>
Co-authored-by: lucasmz <lucasmz@users.noreply.hosted.weblate.org>
Co-authored-by: nautilusx <translate@disroot.org>
Co-authored-by: rehork <cooky@e.email>
Co-authored-by: 大王叫我来巡山 <hamburger2048@users.noreply.hosted.weblate.org>
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/cs/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/de/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/el/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/es/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/fi/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/he/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/it/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/ja/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/pl/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/pt/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/pt_BR/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/ro/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/sv/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/tr/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/zh_Hans/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault_contactsbackup/pt/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault_contactsbackup/ro/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault_storage/pt_BR/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault_storage/ro/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault_storage/sv/
Translation: CalyxOS/Seedvault
Translation: CalyxOS/Seedvault contacts backup
Translation: CalyxOS/Seedvault storage backup
2024-04-24 07:31:58 +02:00
Torsten Grote
11fbd450da
Fix nullability for UserManager in AOSP build (#646) 2024-04-17 00:12:29 +05:30
Torsten Grote
c8d21fcf34 Auto-disable apps that cancel the entire backup
This can happen when the app process gets killed while its BackupAgent is running. There are several qcom apps in the wild that have this issue. These are DoSing our backups and are non-free, so we are defending ourselves against them.
2024-04-16 18:30:20 +05:30
Torsten Grote
499126c459 Log pre-flight errors in BackupMonitor 2024-04-16 18:30:20 +05:30
Torsten Grote
87db20e45f Include user profile name in backup name
so it is easier to identify the right backup if more users backup to the same storage medium.

Change-Id: I56fa93899da3764e20b6aee40adfd52722a05a9f
2024-04-16 18:21:27 +05:30
Torsten Grote
6e63d9bac0 Update build badge in README 2024-04-12 18:47:39 +05:30
Torsten Grote
9557dfd4e7 Fix flakyness in SmallFileBackupIntegrationTest again
Since the chunk gets zipped, the random input data would sometimes differ in size if randomness wasn't truly random, so it could be compressed more.
2024-04-05 17:23:49 +05:30
Torsten Grote
fef6ecc640 Fix flakyness in SmallFileBackupIntegrationTest 2024-04-05 02:56:06 +05:30
Torsten Grote
6caa01f8c5
Merge pull request #628 from grote/583-scheduling
Move to our own scheduling
2024-03-26 12:23:49 -03:00
Torsten Grote
baef15b2bc
Do live-counting of backed up apps for success notification
Previously, we asked the MetadataManager which also includes historic data and may provide misleading totals.
2024-03-19 14:31:36 -03:00
Torsten Grote
db1fc90589
Merge pull request #609 from seedvault-app/feature/rclone
Add support for RoundSync as a storage provider
2024-03-18 10:53:25 -03:00
Torsten Grote
f7730d3034
Report total number of user apps when showing final notification
Before, we showed the number of apps we requested the backup for which in case of non-d2d may be much lower than the number of installed apps.

In the future we may decide to also include certain system apps in that count.
2024-03-13 09:55:46 -03:00
Torsten Grote
178349ff3d
Merge pull request #633 from theimpulson/localTest
BackupScreen: Don't hardcode model name for internal storage
2024-03-12 11:53:21 -03:00
Aayush Gupta
6e4bf90e7c BackupScreen: Don't hardcode model name for internal storage
Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
2024-03-12 19:09:21 +05:30
Torsten Grote
0b021e3b48
Try to close system dialogs of emulator 2024-03-08 09:52:23 -03:00
Torsten Grote
8489753d58
Address review feedback 2024-03-08 09:52:23 -03:00
Torsten Grote
ee581ee652
Initialize backup, when enabling it
For ApkBackup, we need to be initialized. If the system starts with app backup off, we would not initialize which would lead to issues when backing up the APKs.
2024-03-08 09:52:23 -03:00
Torsten Grote
2da989971b
Request @pm@ backup after initialization
to avoid a 2nd restore set being used.

This also changes the initialization behavior to only create the restore set folder and upload the metadata only when we actually need to. This way, double inits are not creating new restore sets on the backup destination.
2024-03-08 09:52:23 -03:00
Torsten Grote
23787a373e
Don't retry instrumentation tests 2024-03-08 09:52:23 -03:00
Torsten Grote
aa1c710624
Stop running instrumentation tests for SDK 33 2024-03-08 09:52:20 -03:00
Torsten Grote
19bfc41d95
Allow backups in metered network, if user wants that 2024-03-08 09:52:07 -03:00
Torsten Grote
4eaa806636
Expose scheduling options in the UI 2024-03-08 09:52:07 -03:00
Torsten Grote
f593b66e00
try more than once to upload metadata after APK backups
Failure to upload metadata after backup up APKs can be critical and flaky I/O can make it fail, so we try again.
2024-03-08 09:52:06 -03:00
Torsten Grote
e7e489e091
Only reschedule next app backup when not on USB storage
Currently, after a manual run, we need to schedule the background backups again, because the scheduling gets lost. However, we need to be careful not to do that when the backup destination is on removable storage. Then we don't want to run.
2024-03-08 09:52:06 -03:00
Torsten Grote
8a870d8942
Use WorkInfo for determining if a backup is already running
Backup and restore is not possible when a backup is running. We used to check notifications for this, but now can use WorkManager's WorkInfo which should be more reliable.

Also, we used to prevent the "Backup now" action when app backup was disabled. But the user may want to do a storage backup. This is now possible.
2024-03-08 09:52:06 -03:00
Torsten Grote
0c1898c198
Properly schedule/cancel backup workers when backup destination changes
When the user changes to USB storage, we need to cancel current schedulings, because the storage is not always available (maybe can use a trigger URI?). And if moving to a non-USB storage, we need to schedule backups again.

Unfortunately, there are two places in the code where we handle storage location changes. Ideally, those get unified at some point.
2024-03-08 09:52:06 -03:00
Torsten Grote
e615402458
During restore, show apps without APK as failed
Previously, we backed up APKs of apps we could not back up (even if APK backup was disabled) so the user had a chance to get at least the apps back when restoring. Now, it is enough to record metadata about the app and the user will be able to manually install the app. The install apps step won't be skipped anymore.
2024-03-08 09:52:06 -03:00
Torsten Grote
6e7bc89e2f
Respect when worker was stopped
and log worker ID as well as object, because we've seen two scheduled workers running at the same time, requesting a backup at the same time. This should not happen.
2024-03-08 09:52:06 -03:00
Torsten Grote
0d7156789e
Guard against BadParcelableException when getting app list
hopefully something rare, but it just happened to me while testing.

It seems it happens when there are many apps installed (>500) and the app list is open while a backup happens. Then, we keep reloading the list and hammer the package manager hard which it seems can't handle it. It does recover on its own though.
2024-03-08 09:52:05 -03:00
Torsten Grote
04fc90e9f7
Migrate to own backup scheduling 2024-03-08 09:52:05 -03:00
Torsten Grote
911a8dabf4
Expose time of next backup in UI
to help debugging scheduling issues
2024-03-08 09:52:05 -03:00
Torsten Grote
8da73ad8d1
Make 'Backup now' action use AppBackupWorker 2024-03-08 09:52:05 -03:00
Torsten Grote
49066be31b
Improve backup notification 2024-03-08 09:52:05 -03:00
Torsten Grote
fcd4e518a5
Move APK backup from BackupCoordinator to new ApkBackupManager
This is a preparation for doing APK backup ourselves in a worker and not hacked into the backup transport. The latter was prone to timeouts by the AOSP backup API. With a worker, we have a bit more control and can schedule backups ourselves.
2024-03-08 09:52:04 -03:00
Torsten Grote
92c87d3b5a
Merge pull request #631 from grote/aosp_atd
Try aosp_atd emulator for instrumentation tests
2024-03-08 09:48:47 -03:00
Torsten Grote
cfe45b4587
Try aosp_atd emulator for instrumentation tests 2024-03-07 17:30:35 -03:00
Torsten Grote
fb4e1711f2 Build AOSP with QPR2 2024-03-07 20:40:09 +05:30
Torsten Grote
0c8fe3ef20 Fix nullability issues that AOSP is complaining about now 2024-03-07 20:40:09 +05:30
Torsten Grote
c33486ee00 Adjust code for new library versions 2024-03-07 20:40:09 +05:30
Torsten Grote
9c7f4cb191 Update dependencies for Android 14 QPR2 2024-03-07 20:40:09 +05:30
Chirayu Desai
635a1ef9b4 strings: Call D2D alpha instead of experimental
Change-Id: I571989a04a2cfaa5684d2d182185799b48b51e9e
2024-02-23 23:37:00 +05:30
Chirayu Desai
2744ccdc7d strings: Call Storage Backup beta instead of experimental
* Let's make it less scary

Change-Id: I889b04eb68df836aea3c5cc4ca97acd3f4c3af54
2024-02-23 23:37:00 +05:30
Torsten Grote
8c27814407
Merge pull request #613 from grote/backup-binder
Use BackupRequester to request backup in chunks
2024-02-22 13:10:23 -03:00
Michael Bestas
a050e73f7d Update SetupWizard dark theme for U
Change-Id: I0a5b1a41cceba2b45b41cfd64e98b8105c8ad6b6
2024-02-22 01:18:45 +05:30
Torsten Grote
a586ee6b14
In instrumentation tests, keep incremental backups
If we request backup in several chunks, packages like 'pm@' or 'android' get backed up for each chunk, so due to incremental backups, we need to keep old data when comparing.
2024-02-14 11:23:22 -03:00
Torsten Grote
b47b4ade1e
Stop cleaning up notification when service is destroyed. 2024-02-13 16:20:02 -03:00
Torsten Grote
4014666c15
Improve notification progress reporting
It is still somewhat buggy when d2d is on, but this is easier to resolve when moving everything to own scheduling.
2024-02-13 16:20:02 -03:00
Torsten Grote
86c603e2d2
Use BackupRequester to request backup in chunks
Otherwise users with lots of installed apps with request a lot of packages causing binder transactions to reach their size limit and crash.
2024-02-13 16:20:02 -03:00
Torsten Grote
81fae1a240 Try to recover from corrupt metadata cache 2024-02-13 23:37:41 +05:30
Torsten Grote
6428399bed Tolerate unexpected exceptions in DocumentsStorage and ApkRestore 2024-02-13 23:36:46 +05:30
Torsten Grote
758186392d Properly handle exception while writing zip chunk entries 2024-02-13 23:36:19 +05:30
Torsten Grote
dc7405474e Improve error reporting when reading snapshot version 2024-02-13 23:36:05 +05:30
Torsten Grote
fd90be8776 Don't include empty dirs in media backup
Otherwise, the directories would be treated as small files and we would try to backup their content which would fail.
2024-02-13 23:36:05 +05:30
Torsten Grote
09b7cabd99 Use own notification ID for success notification
and cancel observer notification when backup is finished. This is because when the success channel is disabled by the user, the observer notification could stick around and would never get removed.
2024-02-13 23:34:59 +05:30
Torsten Grote
cb9d3c701b Fix flaky metadata decoding test 2024-02-13 23:34:59 +05:30
Torsten Grote
fcbd62ba3b Remove warning from d2d expert setting as we now disable system scheduling for d2d 2024-02-13 23:34:59 +05:30
Torsten Grote
c832cd9886 Remove logWorkInfo as some part of it isn't in AOSP version of workmanger
It was meant for debugging only anyway
2024-02-13 23:34:59 +05:30
Torsten Grote
a380445693 Show success notification in a separate notification channel
so the user can disable it. This will be more of an issue now that it comes also for scheduled background backups.
2024-02-13 23:34:59 +05:30
Torsten Grote
de51ad2cc9 Use our own scheduling when doing d2d backups (experimental) 2024-02-13 23:34:59 +05:30
Hosted Weblate
d1f0fef718 Import translations from Weblate
Co-authored-by: 0que <0que@users.noreply.hosted.weblate.org>
Co-authored-by: Hosted Weblate <hosted@weblate.org>
Co-authored-by: Michael Bestas <mkbestas@gmail.com>
Co-authored-by: Morris Son <morrisson42@gmail.com>
Co-authored-by: Mother is a Gambler <dahlan@disroot.org>
Co-authored-by: Pander <pander@users.sourceforge.net>
Co-authored-by: nautilusx <translate@disroot.org>
Co-authored-by: r5jyhte <ioulykttr@proton.me>
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/de/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/el/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/fr/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/id/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/nl/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/pl/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/ru/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault_storage/ru/
Translation: CalyxOS/Seedvault
Translation: CalyxOS/Seedvault storage backup
2024-02-11 02:05:51 +05:30
Steve Soltys
64d0c87013 Add support for RoundSync as a storage provider 2024-01-27 21:27:59 +00:00
Torsten Grote
9c4f9d8a67
Merge pull request #606 from seedvault-app/chore/version-bump
Bump version to 14-4.0 - D2D <3
2024-01-24 17:11:48 -03:00
Chirayu Desai
9097c8ced5 Bump version to 14-4.0 - D2D <3
Change-Id: Ida82c6eafa715069d62dc92eb19accf64ed6d51c
2024-01-24 21:28:09 +05:30
Steve Soltys
695c33e466
Merge pull request #603 from seedvault-app/bugfix/excluded-apk-backups
Stop backing up excluded app APKs
2024-01-19 09:41:51 -05:00
Torsten Grote
bd9ece2b11
Merge pull request #605 from grote/backup-size
Store and show the size of app backups
2024-01-19 11:40:37 -03:00
Steve Soltys
bc189546b3 Add '/build' folders to .gitignore 2024-01-19 03:34:38 +00:00
Steve Soltys
d1e577aec9 Stop backing up excluded app APKs 2024-01-19 03:34:30 +00:00
Torsten Grote
599240c79f
Show size of app backups in Backup Status screen 2024-01-17 13:37:58 -03:00
Torsten Grote
c362da8220
Store size of app backups in metadata 2024-01-16 12:14:28 -03:00
Torsten Grote
0319d733c1
Merge pull request #562 from seedvault-app/feature/d2d-transfer
Add experimental support for forcing D2D transfer backups
2024-01-15 11:24:27 -03:00
Steve Soltys
daaf0e0ecc Add experimental support for forcing D2D transfer backups 2024-01-12 00:12:43 -05:00
Chirayu Desai
57adc57c7f Bump version and set property for testing
* Bump version
  * 33030020 -> 13-3.2
  * 33030021 -> This, d2d test #478
  * 33030022 -> Next, to go back to normal build after testing #489
* Set the testing property to true so that the system
  sends us the right app list
  14597: Optionally have System-scheduled backups act as migrations | https://review.calyxos.org/c/CalyxOS/platform_frameworks_base/+/14597

Change-Id: I278091b6659db095716e01b6c3894ce345219283
2024-01-02 22:02:53 -05:00
Aayush Gupta
57be15abcf colors: Switch to public APIs for colors
Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
2023-11-30 21:39:20 +05:30
t-m-w
c2f737458c Initial support for backup of D2D-only apps
Allow backup of apps that would otherwise only support device-to-device
migration. This is an initial-support patch to help determine the
viability of this approach.

Known issues / TODO:
* System-scheduled backups will not handle D2D-only apps, unless
  accompanied by a framework change forcing OperationType.MIGRATION.
  Backups triggered by the connection of a USB device or by Seedvault's
  StorageBackupService (files) scheduling are not affected, so they
  *will* back up D2D-only apps as expected; otherwise, the user may
  need to perform a backup manually via Backup Now.
* Apps with `allowBackup="false"` will appear in Backup Status under
  "Installed Apps" rather than "Apps that do not allow data backup",
  and their status will always be blank until they have been backed
  up. If they are not eligible for migration, it will never change.

Other notes:
* The unit test for excluding the Storage Plugin provider from backups
  was discussed, deemed unnecessary, and removed.

Co-authored-by: Oliver Scott <olivercscott@gmail.com>
Change-Id: I5a23d68be66f7d8ed755f2bccb9570ab7be49356
2023-11-29 23:55:40 -05:00
Torsten Grote
5d19160602 Pretend to be a device to device data transport
Change-Id: Ieab13cb15b64e09798ec0c1081d3b3cd975e0811
2023-11-29 23:55:40 -05:00
Torsten Grote
640f5b73c6 Fix double start of restore session
We emit the install result of APKs at least two times. When there is no APKs to install, because APK backup was disabled, we would start the restore of app data two times.

This fix waits until the emitted install result is considered finished, so we only start data restore once.
2023-11-28 18:54:32 +05:30
Torsten Grote
d7f985ba8a Add some comments to storage Restore 2023-11-28 18:53:57 +05:30
Tommy Webb
18013c0379 Support installing via F-Droid Basic
If an app being restored was originally installed with F-Droid Basic,
try to install it using F-Droid Basic again.

Change-Id: Ib067389ba20d74596892e24efd561ab2918d62cb
2023-11-27 19:24:36 +05:30
Torsten Grote
392809274c
Merge pull request #563 from seedvault-app/bugfix/binder-exception-too-many-packages
Fix binder exception when restoring a large number of applications
2023-11-27 08:43:08 -03:00
Steve Soltys
b498dab9b1 Apply latest code review suggestions 2023-11-26 14:51:49 -05:00
Torsten Grote
9aa57cacbf
Merge pull request #591 from Uldiniad/android14
fixup! Allow secondary user backup to USB
2023-11-13 11:27:46 -03:00
Oliver Scott
97d2d18a73
fixup! Allow secondary user backup to USB
Issue: calyxos#1058
Change-Id: I4aaadef5954e9c091f7048bffd8e0ed700fdd2e6
2023-11-01 17:19:17 -04:00
Steve Soltys
b1a2c6d4cf Apply code review suggestions 2023-11-01 00:10:00 -04:00
Steve Soltys
6c7afd5f55 Fix binder exception when restoring a large number of applications 2023-10-31 21:38:36 -04:00
t-m-w
a091142a3f Allow restoring data for a greater number of apps
Restore app data in smaller batches when performing a full restoration
from a backup set, to prevent a Binder exception that causes the
process to fail entirely.

Android may encounter this exception when trying to call the
transport.startRestore() method if too many packages are involved; in
testing, 300 is an example of too many. Instead of using
IRestoreSession.restoreAll(), use restorePackages() and provide the
package names in batches of 100.

This issue reveals itself when using SeedVault with the D2D patch and
with an OS, such as stock Pixel OS, that includes an abundance of
packages. (Prior to this patch, the call to restoreAll() meant that the
framework would request data restoration for all packages installed,
even if they were not in the metadata.)

In logs, this issue appears as follows:
```
I BackupManagerService: Full restore; asking about 300 apps
W BpBinder: Large outgoing transaction of 528540 bytes, interface descriptor <uncached descriptor>, code 14
E JavaBinder: !!! FAILED BINDER TRANSACTION !!!  (parcel size = 528540)
E BackupManagerService: Unable to contact transport for restore: data parcel size 528540 bytes
```

Change-Id: Ibb5bb4572d9e873beccd6056da5fe3ae4dce71c2
2023-10-31 21:38:36 -04:00
Steve Soltys
6ce2e27a99
Merge pull request #585 from seedvault-app/feature/kotlin-gradle-build-scripts
Switch to Kotlin build scripts + version catalog
2023-10-19 02:40:44 -04:00
Steve Soltys
b131aaf898 Clean up Gradle build scripts 2023-10-19 00:23:06 -04:00
Steve Soltys
b917293bbc Switch to Kotlin build scripts + version catalog 2023-10-19 00:22:51 -04:00
Steve Soltys
ee3a923034
Merge pull request #582 from seedvault-app/feature/e2e-test-logs
Fix and improve E2E tests
2023-10-17 22:12:54 -04:00
Steve Soltys
551538fd8f Fix AOSP build artifact location 2023-10-17 21:24:38 -04:00
Steve Soltys
8297bb7087 Fix and improve E2E tests 2023-10-17 21:24:38 -04:00
Torsten Grote
28059a50bd
Merge pull request #581 from grote/14-version-upgrades
Version upgrades of included libraries and test dependencies
2023-10-17 11:04:42 -03:00
Steve Soltys
09bc8f0356
Merge pull request #586 from seedvault-app/feature/aosp-build
Build Seedvault with AOSP in CI
2023-10-16 19:38:36 -04:00
Steve Soltys
1a20f63476 Build Seedvault with AOSP in CI 2023-10-16 19:37:35 -04:00
Torsten Grote
f8b94c5f57
Upgrade tink to 1.10.0
1.11.0 is tagged, but not released to maven central, yet.
2023-10-10 15:44:53 -03:00
Torsten Grote
cb95444ad4
Bump minSdk to 33 and upgrade unit test dependencies 2023-10-10 15:44:53 -03:00
Torsten Grote
74566b902a
Upgrade kotlin-bip39-jvm to 1.0.6
Bip39ComparisionTest was run before and after upgrading org.bitcoinj:bitcoinj-core to latest version to ensure that kotlin-bip39 is still behaving the same.

A small tweak in WordListTest was needed because WorldList constructor was made internal.
2023-10-10 15:44:52 -03:00
Torsten Grote
bc90378edf
Merge pull request #579 from seedvault-app/staging/android14-bp
Get app working in Android 14, built via Android.bp
2023-10-10 15:42:29 -03:00
Torsten Grote
0cd6d05b16
Merge pull request #576 from seedvault-app/staging/android14
Gradle updates to match AOSP 14
2023-10-10 12:43:43 -03:00
Chirayu Desai
6cb3b30b84
restore: Runtime-registered broadcasts receivers must specify export behavior
See: https://developer.android.com/about/versions/14/behavior-changes-14#runtime-receivers-exported
Change-Id: I6f80a060370a0b202c277924ea8cbf565bc29d6e
2023-10-10 12:08:19 -03:00
Steve Soltys
aa19ccd557 Make e2e tests run on pull requests 2023-10-10 06:38:31 +05:30
Chirayu Desai
aa0e82cfca ApkInstaller: Supress NewApi for
* Pre-34, this was marked as @hide and @TestApi
* We were using it as a system app with hidden APIs allowed,
  and having added the framework android.jar to gradle
* 91fa0b1298
  made it public, so lint now complains. Silence that.

Change-Id: I5a1ec9847a25a0798726af3867d7660db1528a00
2023-10-09 00:16:15 +05:30
Steve Soltys
1e2d66fccc Pin Android r8 version until we're on AGP 8.2 2023-10-09 00:01:54 +05:30
Chirayu Desai
978ab6897b 14: Bump to JavaVersion.VERSION_17
* AOSP android-14.0.0_r1 bumped Kotlin to 1.8.10
  which requires this

Change-Id: I91f51abbf0b303f3db88c5f4f81c570dd85a6510
2023-10-09 00:01:53 +05:30
Chirayu Desai
eaa3715a6e 14: Match gradle dependencies with AOSP android-14.0.0_r1
* Not many libs got updated, but most significantly, the
  Kotlin compiler was updated

Change-Id: I9454a2e42b6d5da1349f2f662676710212c984f2
2023-10-09 00:01:53 +05:30
Chirayu Desai
a6b32ac3d2 14: Update AOSP libs from gradle, from android-14.0.0_r1
* Compiled with a plain `m`, and then copied over
  from the paths noted in the comments

Change-Id: If5d399d839886c7fe044f5bb7088ed95259e6bf2
2023-10-09 00:01:53 +05:30
Chirayu Desai
82712487fe gradle: Bump to SDK 34
* Android.bp builds mean that we're already on this
* This will need more updates, but let's start here

Change-Id: I924099840e40e2a2b4fd90157f45a160b7c794dd
2023-10-09 00:01:53 +05:30
Steve Soltys
3938549a14 Cancel previous GitHub actions runs when PR updated 2023-10-09 00:01:26 +05:30
Steve Soltys
d678d9a960 Bump emulator image in Gradle task to android-34 2023-10-09 00:01:26 +05:30
Steve Soltys
bf5dc1958c Switch to GitHub actions for E2E tests 2023-10-09 00:01:26 +05:30
Chirayu Desai
fcdacf22a7 14: Add new permission FOREGROUND_SERVICE_DATA_SYNC
* Android.bp build means we get set to targetSdk 34 already

Fixes: Starting FGS with type dataSync targetSDK=34 requires permissions
See: https://developer.android.com/about/versions/14/changes/fgs-types-required#data-sync
Change-Id: I69932d778e870535522e08dff131f1bb1d128955
2023-10-08 00:39:29 +05:30
Chirayu Desai
e6f32510d5 Bump version to 14-3.3
* Android 14 is here!

Change-Id: Ic4249bb1d2a3ac03011f5b7608534ecd526e99c6
2023-10-08 00:39:29 +05:30
Chirayu Desai
ea4e8ec552 README: 13 -> 14
Change-Id: Ia5ebd0f3f1ccb5f9261a956f2485d60f22a5f269
2023-10-08 00:39:29 +05:30
Torsten Grote
2bbeece7b7
Merge pull request #523 from mikeNG/icon-updates
Icon updates
2023-09-26 05:36:36 -03:00
Michael Bestas
a83e36634c seedvault: Enable monochrome icon
Just use foreground icon for now
2023-09-26 02:36:50 +05:30
Michael Bestas
09d6131a1c seedvault: Update app icon
* Regenerate in android studio as a single xml instead of png
* Remove roundIcon, this was only used on sdk 25
* Use device accent for icon background
2023-09-26 02:36:50 +05:30
Michael Bestas
6031f03841 storage demo: Remove roundIcon
This was only used on sdk 25
2023-09-26 02:36:50 +05:30
Hosted Weblate
f30acd8b2d Import translations from Weblate
Co-authored-by: Dan <jonweblin2205@protonmail.com>
Co-authored-by: Eric <hamburger2048@users.noreply.hosted.weblate.org>
Co-authored-by: Fjuro <ifjuro@proton.me>
Co-authored-by: František Oboňa <frantisekobona@gmail.com>
Co-authored-by: Hosted Weblate <hosted@weblate.org>
Co-authored-by: Micovec <jiri.vokrinek@email.cz>
Co-authored-by: Oğuz Ersen <oguz@ersen.moe>
Co-authored-by: Yaron Shahrabani <sh.yaron@gmail.com>
Co-authored-by: gallegonovato <fran-carro@hotmail.es>
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/cs/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/es/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/he/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/sk/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/tr/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/uk/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/zh_Hans/
Translation: CalyxOS/Seedvault
2023-09-25 23:24:03 +05:30
Steve Soltys
6eaba0b87a Wait until storage location is initialized for e2e test 2023-09-25 22:52:01 +05:30
Torsten Grote
ba6dc2ff91
Merge pull request #553 from seedvault-app/feature/e2e-test
Add end-to-end emulator test running on CI
2023-09-25 07:27:26 -03:00
Steve Soltys
ced8803761 Switch ANDROID_SDK_HOME to ANDROID_HOME 2023-09-22 04:12:53 +00:00
Steve Soltys
29bd71bcc9 Intercept and assert on application data in e2e test 2023-09-21 06:51:43 +00:00
Steve Soltys
04c5089113 Start recording screen again if we get cut off after 3 minutes 2023-09-14 18:42:22 +00:00
Steve Soltys
59cef31183 Address review comments, add screen recording, use test backup data 2023-09-14 18:11:45 +00:00
Steve Soltys
f1238977d0 Add end-to-end emulator test running on CI 2023-09-14 18:11:45 +00:00
Steve Soltys
c96f1c961a
Merge pull request #552 from seedvault-app/feature/local-development-improvements
Add support for local development with an emulator
2023-09-14 14:06:50 -04:00
Steve Soltys
a922b69094 Add support for local development with an emulator 2023-09-14 17:33:30 +00:00
Steve Soltys
77fed00a74
Merge pull request #551 from seedvault-app/bugfix/fix-no-manage-documents-permission
Support a lack of MANAGE_DOCUMENTS permission
2023-09-14 13:33:01 -04:00
Torsten Grote
1e69831244 Improving support for missing MANAGE_DOCUMENTS permission 2023-09-14 17:23:08 +00:00
t-m-w
208dbd6a60 Support a lack of MANAGE_DOCUMENTS permission
When `android.permission.MANAGE_DOCUMENTS` is not granted, Seedvault
prompts to select a storage location. Do not insist on resolving the
storage's actual root, as it will likely (or perhaps always) fail.
Use a fake storage root as is done for USB and app-based options.

Known issues:
* Selected location is assumed not to be USB and not to require
  network access in its storage options.

Change-Id: I357b4c68673d71c087be41e9c94c2841c1d6658e
2023-09-14 17:22:50 +00:00
Aayush Gupta
da5205c0e9
Merge pull request #526 from theimpulson/android13-dependencyUpdates
Android13 QPR2 Dependency & Misc Updates
2023-08-04 16:41:32 +08:00
Aayush Gupta
63bfb6be55 Update possible github actions
Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
2023-08-03 01:14:16 +08:00
Aayush Gupta
6ca1f2792f Bump to AGP and Gradle 8.x
Disable new R8 mode and resource namespacing for now to avoid build failures.
These needs to be worked on before they can be enabled.

Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
2023-08-03 00:56:59 +08:00
Aayush Gupta
4a31035585 Drop packageName from manifests for tests
Tests are Gradle-only and keeping this in manifest results in namespace collision
Ref: https://developer.android.com/build/configure-app-module#change-namespace-for-testing

Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
2023-08-03 00:08:57 +08:00
Aayush Gupta
8b63a0a7f9 Set appropriate namespace in all modules
Required by new AGP versions

Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
2023-08-03 00:08:57 +08:00
Aayush Gupta
b330b7baa6 Switch to new Sdk version properties
Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
2023-08-03 00:08:57 +08:00
Aayush Gupta
cba065fe56 Sync appropriate protoc artifact for m1
Fixes compilation on M1 macOS. Check https://github.com/grpc/grpc-java/issues/7690 for further info

Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
2023-08-03 00:08:57 +08:00
Aayush Gupta
64ecd5c061 Drop buildToolsVersion
If you're using Android plugin for Gradle 3.0.0 or higher, your project automatically uses a default version of the build tools that the plugin specifies

Ref: https://developer.android.com/tools/releases/build-tools

Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
2023-08-03 00:08:57 +08:00
Aayush Gupta
d5320918dc Switch from -Xopt-in to -opt-in
w: Argument -Xopt-in is deprecated. Please use -opt-in instead
w: C:\Users\aayus\StudioProjects\seedvault\storage\demo\src\main\java\de\grobox\storagebackuptester\restore\DemoSnapshotFragment.kt: (34, 31): 'onBackPressed(): Unit' is deprecated. Overrides deprecated member in 'androidx.core.app.ComponentActivity'. Deprecated in Java

w: Argument -Xopt-in is deprecated. Please use -opt-in instead
w: C:\Users\aayus\StudioProjects\seedvault\storage\lib\src\main\java\org\calyxos\backup\storage\backup\BackupService.kt: (35, 9): This is a delicate API and its use requires care. Make sure you fully read and understand documentation of the declaration that is marked as a delicate API.
w: C:\Users\aayus\StudioProjects\seedvault\storage\lib\src\main\java\org\calyxos\backup\storage\restore\RestoreService.kt: (49, 9): This is a delicate API and its use requires care. Make sure you fully read and understand documentation of the declaration that is marked as a delicate API.

Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
2023-08-03 00:08:57 +08:00
Aayush Gupta
efee38ae39 Bump ktlint Gradle plugin to 11.3.1
Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
2023-08-03 00:08:53 +08:00
Aayush Gupta
845709246f Bump dependencies to Android 13 QPR2 release
Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
2023-08-03 00:02:19 +08:00
Aayush Gupta
1d9cb146f8 Set root project's name to Seedvault
Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
2023-07-03 23:28:27 +05:30
Aayush Gupta
1943595f11 Migrate to new plugins and dependency management system
* Ensure every plugin is present in project's plugin block with version
* Switch to full plugin id for jetbrains plugins
* Move plugin and dependency repos to settings

Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
2023-07-03 23:28:27 +05:30
Aayush Gupta
b7c1459aca Bump to latest stable AGP and Gradle versions
Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
2023-07-03 23:28:27 +05:30
Aayush Gupta
591e9dbc68 Bump kotlin to 1.7.20 based on Android 13 QPR2 release
Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
2023-07-03 23:28:27 +05:30
Michael Bestas
90c8a3fb12 Remove androidx.annotation.VisibleForTesting.PRIVATE usage
VisibleForTesting defaults to private anyway, fixes build in 13 QPR3.

Change-Id: Icdbbd63f1f0fde2148491feefbc7221e91590881
2023-06-14 15:37:50 +05:30
Hosted Weblate
5448ef8652 Import translations from Weblate
Co-authored-by: Hosted Weblate <hosted@weblate.org>
Co-authored-by: Milo Ivir <mail@milotype.de>
Co-authored-by: Pander <pander@users.sourceforge.net>
Co-authored-by: Ram <airavatam@tutanota.com>
Co-authored-by: Yuya <yuyaj@tutanota.com>
Co-authored-by: kbci_wcn <kbci_wcn@aleeas.com>
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/ca/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/ja/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/nl/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault_contactsbackup/hr/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault_contactsbackup/ml/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault_storage/ml/
Translation: CalyxOS/Seedvault
Translation: CalyxOS/Seedvault contacts backup
Translation: CalyxOS/Seedvault storage backup
2023-05-27 04:02:43 +05:30
nettnikl
cc86febbb9 Include extractor project in README.md 2023-05-19 21:09:16 +05:30
Hosted Weblate
8bea1be060 Import translations from Weblate
Co-authored-by: Hosted Weblate <hosted@weblate.org>
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/
Translation: CalyxOS/Seedvault
2023-03-29 19:49:31 +05:30
Hosted Weblate
80d3b0e880 Import translations from Weblate
Co-authored-by: Hosted Weblate <hosted@weblate.org>
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/
Translation: CalyxOS/Seedvault
2023-03-29 04:28:27 +05:30
Hosted Weblate
be5d2e0d53 Import translations from Weblate
Co-authored-by: Dan <denqwerta@gmail.com>
Co-authored-by: Eric <hamburger2048@users.noreply.hosted.weblate.org>
Co-authored-by: Felipe Nogueira <contato.fnog@gmail.com>
Co-authored-by: Hosted Weblate <hosted@weblate.org>
Co-authored-by: Leon Omelan <rozpierog@gmail.com>
Co-authored-by: Michael Bestas <mkbestas@gmail.com>
Co-authored-by: Oğuz Ersen <oguz@ersen.moe>
Co-authored-by: Pander <pander@users.sourceforge.net>
Co-authored-by: Reikimann <krellegaming@gmail.com>
Co-authored-by: Tom Sawyer <translate@grymkoll.simplelogin.com>
Co-authored-by: Translator-3000 <weblate.m1d0h@8shield.net>
Co-authored-by: Yaron Shahrabani <sh.yaron@gmail.com>
Co-authored-by: Zkdc <Zkdc2345@qq.com>
Co-authored-by: gallegonovato <fran-carro@hotmail.es>
Co-authored-by: gnu-ewm <gnu.ewm@protonmail.com>
Co-authored-by: nautilusx <translate@disroot.org>
Co-authored-by: slundi <slundi@gmail.com>
Co-authored-by: ssantos <ssantos@web.de>
Co-authored-by: Óscar Fernández Díaz <oscfdezdz@users.noreply.hosted.weblate.org>
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/de/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/el/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/es/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/fr/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/gl/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/he/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/it/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/nl/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/pl/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/pt/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/pt_BR/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/pt_PT/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/sv/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/tr/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/uk/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/zh_Hans/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault_contactsbackup/da/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault_contactsbackup/nl/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault_storage/nl/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault_storage/pl/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault_storage/pt/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault_storage/pt_BR/
Translation: CalyxOS/Seedvault
Translation: CalyxOS/Seedvault contacts backup
Translation: CalyxOS/Seedvault storage backup
2023-03-29 03:16:45 +05:30
Torsten Grote
923fb51f43 Ignore extra translations 2023-03-10 00:07:24 +05:30
Torsten Grote
480d3aa589 Add funding section to README 2023-03-10 00:07:24 +05:30
Torsten Grote
9ae32a9bac Redesign About dialog 2023-03-10 00:07:24 +05:30
Michael Bestas
0e147786b4 Remove compatibility symlinks for weblate translations
Weblate uses the correct locales now
2023-03-09 04:00:02 +05:30
Michael Bestas
f016724b1f Make contactsbackup REUSE compliant 2023-03-09 02:42:03 +05:30
Michael Bestas
076bd71c1d contactsbackup: Add SPDX copyright headers 2023-03-09 02:42:03 +05:30
Michael Bestas
efaa1316c8 Make storage REUSE compliant 2023-03-09 02:42:03 +05:30
Michael Bestas
66209f78f2 storage: Add SPDX copyright headers 2023-03-09 02:42:03 +05:30
Michael Bestas
366ea62895 storage: Add missing newlines at the end of the files 2023-03-09 02:42:03 +05:30
Michael Bestas
cd9ff5e6c6 Add .idea copyright configuration 2023-03-09 02:42:03 +05:30
Torsten Grote
630b2d1e70
Merge pull request #508 from chirayudesai/506-block-screenshots
Disable screenshots on more recovery code screens
2023-01-23 18:17:58 -03:00
Chirayu Desai
23abc02d69 Disable screenshots on more recovery code screens
* Basically try to cover all screens that may have a recovery code

Fixes: #506
Change-Id: If0143b71596ff470a04982d8f87b7a622d362309
2023-01-20 23:21:16 +05:30
Torsten Grote
8367e99421
Merge pull request #498 from chirayudesai/13-3.3
Bump version to 13-3.3
2023-01-17 14:31:31 -03:00
Chirayu Desai
eebeff90ff Bump version to 13-3.3
* Release early, release often

Change-Id: Id408dd7463a5c9a51dafea0e45cbda122ba26866
2023-01-11 19:23:02 +05:30
Chirayu Desai
ebed17ee58 Mark Nextcloud as not recommended
* We've had a love/hate relationship with the combination of
  SAF + Nextcloud app + Nextcloud server
* SAF is quite limiting, and that causes it's own issues
* On top of that, Nextcloud app has it's own issues. We've
  even sent patches for some things, but there's only so much one can do
  https://github.com/nextcloud/android/pulls?q=is%3Apr+author%3Agrote
* With the DAVx5 WebDAV support, it seems to work better.
* However, most recently a server side change broke things entirely, with either apps
  https://github.com/seedvault-app/seedvault/issues/490#issuecomment-1368032414
* Due of all of this, it just leads to a bad backup experience.
  As such, let's just say this is not recommended at all entirely
* Hopefully in the future we'll be able to support more options

Change-Id: I0b46dd11df7c31606131bf311583fe4777536463
2023-01-11 19:19:41 +05:30
t-m-w
5d0aca1b49 Warn before turning off backups
Let the user know that turning off backups will require a new backup
set to be created.

Requires: https://github.com/seedvault-app/seedvault/pull/496

Change-Id: I22a1cebd272ac43cab6c68b99ace5919d6a7a9f5
2023-01-06 20:09:38 +05:30
Torsten Grote
87a800438b Always start a new RestoreSet when initializing the device
This avoids deleting the current backup when the user disables backups (or the system decides to do a random re-init).
2023-01-06 20:09:16 +05:30
Denham McLaren
bedba071df Translated using Weblate (English (Australia))
Currently translated at 100.0% (17 of 17 strings)

Translated using Weblate (English (Australia))

Currently translated at 100.0% (1 of 1 strings)

Translated using Weblate (English (Australia))

Currently translated at 100.0% (182 of 182 strings)

Translated using Weblate (English (Australia))

Currently translated at 10.9% (20 of 182 strings)

Co-authored-by: Denham McLaren <denhamrock@gmail.com>
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/en_AU/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault_contactsbackup/en_AU/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault_storage/en_AU/
Translation: CalyxOS/Seedvault
Translation: CalyxOS/Seedvault contacts backup
Translation: CalyxOS/Seedvault storage backup
2023-01-06 04:19:45 +05:30
Translator-3000
2685d57bda Translated using Weblate (Italian)
Currently translated at 100.0% (17 of 17 strings)

Translated using Weblate (Italian)

Currently translated at 100.0% (1 of 1 strings)

Translated using Weblate (Italian)

Currently translated at 100.0% (182 of 182 strings)

Co-authored-by: Translator-3000 <weblate.m1d0h@8shield.net>
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/it/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault_contactsbackup/it/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault_storage/it/
Translation: CalyxOS/Seedvault
Translation: CalyxOS/Seedvault contacts backup
Translation: CalyxOS/Seedvault storage backup
2023-01-06 04:19:45 +05:30
Yaron Shahrabani
6a12cf9480 Translated using Weblate (Hebrew)
Currently translated at 100.0% (182 of 182 strings)

Co-authored-by: Yaron Shahrabani <sh.yaron@gmail.com>
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/he/
Translation: CalyxOS/Seedvault
2023-01-06 04:19:45 +05:30
Егор Ермаков
45349e2e07 Translated using Weblate (Russian)
Currently translated at 100.0% (182 of 182 strings)

Co-authored-by: Егор Ермаков <eg.ermakov2016@yandex.ru>
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/ru/
Translation: CalyxOS/Seedvault
2023-01-06 04:19:45 +05:30
Dan
b7f187451f Translated using Weblate (Ukrainian)
Currently translated at 100.0% (17 of 17 strings)

Translated using Weblate (Ukrainian)

Currently translated at 100.0% (1 of 1 strings)

Translated using Weblate (Ukrainian)

Currently translated at 100.0% (182 of 182 strings)

Co-authored-by: Dan <denqwerta@gmail.com>
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/uk/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault_contactsbackup/uk/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault_storage/uk/
Translation: CalyxOS/Seedvault
Translation: CalyxOS/Seedvault contacts backup
Translation: CalyxOS/Seedvault storage backup
2023-01-06 04:19:45 +05:30
nautilusx
2166cae00a Translated using Weblate (German)
Currently translated at 100.0% (182 of 182 strings)

Co-authored-by: nautilusx <translate@disroot.org>
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/de/
Translation: CalyxOS/Seedvault
2023-01-06 04:19:45 +05:30
Oğuz Ersen
5c4da3ffa6 Translated using Weblate (Turkish)
Currently translated at 100.0% (182 of 182 strings)

Co-authored-by: Oğuz Ersen <oguz@ersen.moe>
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/tr/
Translation: CalyxOS/Seedvault
2023-01-06 04:19:45 +05:30
gallegonovato
43ca12686f Translated using Weblate (Spanish)
Currently translated at 100.0% (182 of 182 strings)

Co-authored-by: gallegonovato <fran-carro@hotmail.es>
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/es/
Translation: CalyxOS/Seedvault
2023-01-06 04:19:45 +05:30
TobiGr
c43274e6a0 Translated using Weblate (German)
Currently translated at 99.4% (181 of 182 strings)

Co-authored-by: TobiGr <tobigr@mail.de>
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/de/
Translation: CalyxOS/Seedvault
2023-01-06 04:19:45 +05:30
Eric
3e25c3f54f Translated using Weblate (Chinese (Simplified))
Currently translated at 100.0% (182 of 182 strings)

Co-authored-by: Eric <hamburger1024@duck.com>
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/zh_Hans/
Translation: CalyxOS/Seedvault
2023-01-06 04:19:45 +05:30
Gediminas Murauskas
2d2e9dacb6 Translated using Weblate (Lithuanian)
Currently translated at 100.0% (182 of 182 strings)

Co-authored-by: Gediminas Murauskas <muziejusinfo@gmail.com>
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/lt/
Translation: CalyxOS/Seedvault
2023-01-06 04:19:45 +05:30
Torsten Grote
03ef65b5db Pre-grant ACCESS_MEDIA_LOCATION permission 2023-01-06 00:15:03 +05:30
Torsten Grote
4b9e2bb9f3 Show foreground notification right away when doing manual backup 2023-01-06 00:02:58 +05:30
Torsten Grote
594d5e17b5
Merge pull request #488 from chirayudesai/gh-actions
gh-actions: Upload debug apks as artifacts
2023-01-03 14:54:48 -03:00
Chirayu Desai
4520ed4fff
Bump version to 13-3.2 (#487)
* Spread out the version code a bit to allow for more
  releases per one name

Change-Id: I70b6ba92e359a1f229ee470f4032c04b9fd25e5b
2023-01-02 13:02:43 -03:00
Chirayu Desai
f20507fdc2 gh-actions: Upload debug apks as artifacts
Change-Id: I794a8cf20a77ed32d975a2eff834cdd703c6e35e
2022-12-30 03:43:07 +05:30
Michael Bestas
644e5c10de Translated using Weblate (Greek)
Currently translated at 100.0% (182 of 182 strings)

Co-authored-by: Michael Bestas <mkbestas@gmail.com>
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/el/
Translation: CalyxOS/Seedvault
2022-12-01 07:05:47 +05:30
blueline
f9e33337e6 Translated using Weblate (French (Canada))
Currently translated at 100.0% (1 of 1 strings)

Translated using Weblate (French (Canada))

Currently translated at 4.4% (8 of 179 strings)

Co-authored-by: blueline <blueline3@proton.me>
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/fr_CA/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault_contactsbackup/fr_CA/
Translation: CalyxOS/Seedvault
Translation: CalyxOS/Seedvault contacts backup
2022-12-01 06:27:15 +05:30
ssantos
3a2025f5b2 Translated using Weblate (Portuguese (Portugal))
Currently translated at 88.2% (158 of 179 strings)

Co-authored-by: ssantos <ssantos@web.de>
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/pt_PT/
Translation: CalyxOS/Seedvault
2022-12-01 06:27:15 +05:30
Gediminas Murauskas
9ca8c29086 Translated using Weblate (Lithuanian)
Currently translated at 100.0% (17 of 17 strings)

Translated using Weblate (Lithuanian)

Currently translated at 100.0% (1 of 1 strings)

Translated using Weblate (Lithuanian)

Currently translated at 100.0% (179 of 179 strings)

Co-authored-by: Gediminas Murauskas <muziejusinfo@gmail.com>
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/lt/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault_contactsbackup/lt/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault_storage/lt/
Translation: CalyxOS/Seedvault
Translation: CalyxOS/Seedvault contacts backup
Translation: CalyxOS/Seedvault storage backup
2022-12-01 06:27:15 +05:30
이정희
e97c310f5e Translated using Weblate (Korean)
Currently translated at 100.0% (179 of 179 strings)

Translated using Weblate (Korean)

Currently translated at 100.0% (17 of 17 strings)

Translated using Weblate (Korean)

Currently translated at 100.0% (179 of 179 strings)

Co-authored-by: 이정희 <daemul72@gmail.com>
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/ko/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault_storage/ko/
Translation: CalyxOS/Seedvault
Translation: CalyxOS/Seedvault storage backup
2022-12-01 06:27:15 +05:30
Vri 🌈
5935a66a4f Translated using Weblate (German)
Currently translated at 100.0% (179 of 179 strings)

Co-authored-by: Vri 🌈 <weblate@vrifox.cc>
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/de/
Translation: CalyxOS/Seedvault
2022-12-01 06:27:15 +05:30
Temuri Doghonadze
f090ad57c5 Translated using Weblate (Georgian)
Currently translated at 100.0% (1 of 1 strings)

Co-authored-by: Temuri Doghonadze <temuri.doghonadze@gmail.com>
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault_contactsbackup/ka/
Translation: CalyxOS/Seedvault contacts backup
2022-12-01 06:27:15 +05:30
gallegonovato
68c764b60f Translated using Weblate (Spanish)
Currently translated at 100.0% (179 of 179 strings)

Translated using Weblate (Spanish)

Currently translated at 100.0% (179 of 179 strings)

Translated using Weblate (Spanish)

Currently translated at 100.0% (179 of 179 strings)

Translated using Weblate (Spanish)

Currently translated at 100.0% (179 of 179 strings)

Translated using Weblate (Spanish)

Currently translated at 100.0% (179 of 179 strings)

Translated using Weblate (Spanish)

Currently translated at 100.0% (179 of 179 strings)

Translated using Weblate (Spanish)

Currently translated at 100.0% (179 of 179 strings)

Translated using Weblate (Spanish)

Currently translated at 100.0% (17 of 17 strings)

Translated using Weblate (Galician)

Currently translated at 100.0% (17 of 17 strings)

Translated using Weblate (Galician)

Currently translated at 100.0% (1 of 1 strings)

Translated using Weblate (Spanish)

Currently translated at 100.0% (179 of 179 strings)

Translated using Weblate (Spanish)

Currently translated at 100.0% (179 of 179 strings)

Co-authored-by: gallegonovato <fran-carro@hotmail.es>
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/es/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault_contactsbackup/gl/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault_storage/es/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault_storage/gl/
Translation: CalyxOS/Seedvault
Translation: CalyxOS/Seedvault contacts backup
Translation: CalyxOS/Seedvault storage backup
2022-12-01 06:27:15 +05:30
Martin
36cce354c3 Translated using Weblate (Spanish (American))
Currently translated at 94.1% (16 of 17 strings)

Translated using Weblate (Spanish)

Currently translated at 100.0% (17 of 17 strings)

Translated using Weblate (Spanish (American))

Currently translated at 100.0% (1 of 1 strings)

Co-authored-by: Martin <martinjason12345678@gmail.com>
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault_contactsbackup/es_US/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault_storage/es/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault_storage/es_US/
Translation: CalyxOS/Seedvault contacts backup
Translation: CalyxOS/Seedvault storage backup
2022-12-01 06:27:15 +05:30
Launacloud
41e06324ad Translated using Weblate (Portuguese (Brazil))
Currently translated at 98.3% (176 of 179 strings)

Co-authored-by: Launacloud <CLOUDAPPSLAURA@gmail.com>
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/pt_BR/
Translation: CalyxOS/Seedvault
2022-12-01 06:27:15 +05:30
bruh
78bdba0af4 Translated using Weblate (Vietnamese)
Currently translated at 100.0% (179 of 179 strings)

Co-authored-by: bruh <quangtrung02hn16@gmail.com>
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/vi/
Translation: CalyxOS/Seedvault
2022-12-01 06:27:15 +05:30
JBL
c088c5ae5e Translated using Weblate (French)
Currently translated at 100.0% (17 of 17 strings)

Co-authored-by: JBL <jb.lze@tutanota.com>
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault_storage/fr/
Translation: CalyxOS/Seedvault storage backup
2022-12-01 06:27:15 +05:30
Maxime Leroy
ec53059cfa Translated using Weblate (French)
Currently translated at 100.0% (179 of 179 strings)

Translated using Weblate (French)

Currently translated at 100.0% (170 of 170 strings)

Co-authored-by: Maxime Leroy <lisacintosh@gmail.com>
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/fr/
Translation: CalyxOS/Seedvault
2022-12-01 06:27:15 +05:30
kbci_wcn
aae2f5dabb Translated using Weblate (Catalan)
Currently translated at 100.0% (179 of 179 strings)

Translated using Weblate (Catalan)

Currently translated at 100.0% (17 of 17 strings)

Translated using Weblate (Catalan)

Currently translated at 100.0% (170 of 170 strings)

Co-authored-by: kbci_wcn <kbci_wcn@aleeas.com>
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/ca/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault_storage/ca/
Translation: CalyxOS/Seedvault
Translation: CalyxOS/Seedvault storage backup
2022-12-01 06:27:15 +05:30
Егор Ермаков
8041680e19 Translated using Weblate (Russian)
Currently translated at 100.0% (179 of 179 strings)

Translated using Weblate (Russian)

Currently translated at 100.0% (17 of 17 strings)

Translated using Weblate (Russian)

Currently translated at 98.8% (177 of 179 strings)

Translated using Weblate (Russian)

Currently translated at 100.0% (170 of 170 strings)

Co-authored-by: Егор Ермаков <eg.ermakov2016@yandex.ru>
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/ru/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault_storage/ru/
Translation: CalyxOS/Seedvault
Translation: CalyxOS/Seedvault storage backup
2022-12-01 06:27:15 +05:30
Micovec
15dda1bfab Translated using Weblate (Czech)
Currently translated at 100.0% (17 of 17 strings)

Translated using Weblate (Czech)

Currently translated at 97.2% (174 of 179 strings)

Translated using Weblate (Czech)

Currently translated at 96.6% (173 of 179 strings)

Translated using Weblate (Czech)

Currently translated at 99.4% (169 of 170 strings)

Co-authored-by: Micovec <jiri.vokrinek@email.cz>
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/cs/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault_storage/cs/
Translation: CalyxOS/Seedvault
Translation: CalyxOS/Seedvault storage backup
2022-12-01 06:27:15 +05:30
Pietro Cappuccino
31b3af2a05 Translated using Weblate (Italian)
Currently translated at 70.0% (119 of 170 strings)

Co-authored-by: Pietro Cappuccino <p.cappuccino@tiscali.it>
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/it/
Translation: CalyxOS/Seedvault
2022-12-01 06:27:15 +05:30
Doan Quan Tien
e2c73b0660 Translated using Weblate (Vietnamese)
Currently translated at 100.0% (170 of 170 strings)

Co-authored-by: Doan Quan Tien <doanquantien1@outlook.com>
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/vi/
Translation: CalyxOS/Seedvault
2022-12-01 06:27:15 +05:30
Michael Bestas
a27541f87a Translated using Weblate (Greek)
Currently translated at 100.0% (17 of 17 strings)

Translated using Weblate (Greek)

Currently translated at 100.0% (179 of 179 strings)

Translated using Weblate (Greek)

Currently translated at 100.0% (170 of 170 strings)

Co-authored-by: Michael Bestas <mkbestas@gmail.com>
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/el/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault_storage/el/
Translation: CalyxOS/Seedvault
Translation: CalyxOS/Seedvault storage backup
2022-12-01 06:27:15 +05:30
Óscar Fernández Díaz
b89c97370f Translated using Weblate (Spanish)
Currently translated at 100.0% (179 of 179 strings)

Translated using Weblate (Spanish)

Currently translated at 100.0% (170 of 170 strings)

Co-authored-by: Óscar Fernández Díaz <oscfdezdz@tuta.io>
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/es/
Translation: CalyxOS/Seedvault
2022-12-01 06:27:15 +05:30
fawaz006
edad362ea8 Translated using Weblate (Arabic)
Currently translated at 100.0% (16 of 16 strings)

Translated using Weblate (Arabic)

Currently translated at 100.0% (1 of 1 strings)

Translated using Weblate (Arabic)

Currently translated at 13.5% (23 of 170 strings)

Co-authored-by: fawaz006 <fawaz27000@hotmail.com>
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/ar/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault_contactsbackup/ar/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault_storage/ar/
Translation: CalyxOS/Seedvault
Translation: CalyxOS/Seedvault contacts backup
Translation: CalyxOS/Seedvault storage backup
2022-12-01 06:27:15 +05:30
Eric
a30ea61693 Translated using Weblate (Chinese (Simplified))
Currently translated at 100.0% (17 of 17 strings)

Translated using Weblate (Chinese (Simplified))

Currently translated at 100.0% (179 of 179 strings)

Translated using Weblate (Chinese (Simplified))

Currently translated at 100.0% (170 of 170 strings)

Co-authored-by: Eric <alchemillatruth@purelymail.com>
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/zh_Hans/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault_storage/zh_Hans/
Translation: CalyxOS/Seedvault
Translation: CalyxOS/Seedvault storage backup
2022-12-01 06:27:15 +05:30
Yaron Shahrabani
d233775501 Translated using Weblate (Hebrew)
Currently translated at 100.0% (179 of 179 strings)

Translated using Weblate (Hebrew)

Currently translated at 100.0% (17 of 17 strings)

Translated using Weblate (Hebrew)

Currently translated at 100.0% (170 of 170 strings)

Co-authored-by: Yaron Shahrabani <sh.yaron@gmail.com>
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/he/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault_storage/he/
Translation: CalyxOS/Seedvault
Translation: CalyxOS/Seedvault storage backup
2022-12-01 06:27:15 +05:30
nautilusx
df99fc6a1e Translated using Weblate (German)
Currently translated at 100.0% (179 of 179 strings)

Translated using Weblate (German)

Currently translated at 100.0% (17 of 17 strings)

Translated using Weblate (German)

Currently translated at 100.0% (179 of 179 strings)

Translated using Weblate (German)

Currently translated at 100.0% (170 of 170 strings)

Co-authored-by: nautilusx <translate@disroot.org>
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/de/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault_storage/de/
Translation: CalyxOS/Seedvault
Translation: CalyxOS/Seedvault storage backup
2022-12-01 06:27:15 +05:30
Oğuz Ersen
edb2c7ae40 Translated using Weblate (Turkish)
Currently translated at 100.0% (17 of 17 strings)

Translated using Weblate (Turkish)

Currently translated at 100.0% (179 of 179 strings)

Translated using Weblate (Turkish)

Currently translated at 100.0% (170 of 170 strings)

Co-authored-by: Oğuz Ersen <oguz@ersen.moe>
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/tr/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault_storage/tr/
Translation: CalyxOS/Seedvault
Translation: CalyxOS/Seedvault storage backup
2022-12-01 06:27:15 +05:30
Prachi Joshi
8764e335d6 Translated using Weblate (Marathi)
Currently translated at 100.0% (1 of 1 strings)

Co-authored-by: Prachi Joshi <josprachi@yahoo.com>
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault_contactsbackup/mr/
Translation: CalyxOS/Seedvault contacts backup
2022-12-01 06:27:15 +05:30
Allan Nordhøy
7a00678372 Translated using Weblate (Norwegian Bokmål)
Currently translated at 87.5% (14 of 16 strings)

Translated using Weblate (Norwegian Bokmål)

Currently translated at 100.0% (1 of 1 strings)

Translated using Weblate (Norwegian Bokmål)

Currently translated at 76.9% (130 of 169 strings)

Co-authored-by: Allan Nordhøy <epost@anotheragency.no>
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/nb_NO/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault_contactsbackup/nb_NO/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault_storage/nb_NO/
Translation: CalyxOS/Seedvault
Translation: CalyxOS/Seedvault contacts backup
Translation: CalyxOS/Seedvault storage backup
2022-12-01 06:27:15 +05:30
lx3k
c9f3324ec0 Translated using Weblate (Japanese)
Currently translated at 93.7% (15 of 16 strings)

Translated using Weblate (Japanese)

Currently translated at 100.0% (1 of 1 strings)

Translated using Weblate (Japanese)

Currently translated at 88.1% (149 of 169 strings)

Co-authored-by: lx3k <lx3kvdms@anonaddy.me>
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/ja/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault_contactsbackup/ja/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault_storage/ja/
Translation: CalyxOS/Seedvault
Translation: CalyxOS/Seedvault contacts backup
Translation: CalyxOS/Seedvault storage backup
2022-12-01 06:27:15 +05:30
Weblate
8193233c8f Added translation using Weblate (Asturian)
Added translation using Weblate (Gaelic)

Added translation using Weblate (Asturian)

Added translation using Weblate (Welsh)

Added translation using Weblate (Gaelic)

Added translation using Weblate (Welsh)

Added translation using Weblate (Asturian)

Added translation using Weblate (Gaelic)

Added translation using Weblate (Welsh)

Co-authored-by: Weblate <noreply@weblate.org>
2022-12-01 06:27:15 +05:30
t-m-w
4a67b9e5eb Update permissions for log feature
Update the bundled privileged permissions allowlist to include the
newly-added READ_LOGS permission. Otherwise, Android will not boot
with the latest version of Seedvault bundled.

Change-Id: I10fd397c2c1b03201165d70a7e43d18642d1d236
2022-12-01 06:23:35 +05:30
Torsten Grote
271b9a560f Remove some code warnings 2022-11-16 19:19:56 +05:30
Torsten Grote
1a7fc5f028 Add expert option to save logs 2022-11-16 19:19:56 +05:30
Torsten Grote
374ba8b64f Remove permission requirement in a better way for debug builds
and reformat some SettingsFragment details
2022-11-12 03:38:14 +05:30
Chirayu Desai
c6a77904a6
RecoveryCode: Allow screenshots on debug builds (#446)
* We already pre-fill the code on debug builds to make testing easier
* Allow screenshots too so we don't have to note down the code right away
  when testing

Change-Id: Ie9cc3080616b78a6e5f9b427c080f10c146a036d
2022-10-14 16:30:18 -03:00
Alexander Martinz
0106c1911a Document POST_NOTIFICATIONS permission usage
Change-Id: Ie9d2b9bc06aba0dfbd268408220ba54081137b26
Signed-off-by: Alexander Martinz <amartinz@shiftphones.com>
2022-10-06 20:07:13 +05:30
Alexander Martinz
7799ad1339 Document that MANAGE_DOCUMENTS is optional
MR #151 implemented a fallback if MANAGE_DOCUMENTS is not granted,
which falls back to show a file chooser to the user to manually
select the storage root.

Document this behavior in the manifest as well, as the permission
causes some certification tests to fail (#453).

Change-Id: I3271b7969aacc014349766a022f13a00bea9ff85
Signed-off-by: Alexander Martinz <amartinz@shiftphones.com>
2022-10-06 20:07:13 +05:30
Michael Bestas
a0ec8a5ecc Properly pre-grant notification permission 2022-09-14 00:10:44 +05:30
Michael Bestas
e78094e197 Android.bp: whitelist -> allowlist 2022-09-14 00:10:44 +05:30
Chirayu Desai
270e0baeff
README: Add more details about branching (#445) 2022-09-13 14:53:10 -03:00
Aayush Gupta
a0d14910f6
Merge pull request #441 from grote/splitSourceDirs-npe
Handle null better for Android 13
2022-09-09 10:33:25 +05:30
Torsten Grote
dfc9aeee28
Expect BackupObserver to be called with null packages 2022-09-08 17:45:17 -03:00
Torsten Grote
848ed51de4
Expect ApplicationInfo#splitSourceDirs to be null
Also handle errors like these a bit better
2022-09-08 17:40:41 -03:00
Aayush Gupta
f5c58363ef
Merge pull request #439 from mikeNG/android13-aosp-fix
{seedvault|storage}: Add explicit dependencies for androidx.{fragment|activity}
2022-09-02 13:23:21 +05:30
Michael Bestas
525a198ec8
{seedvault|storage}: Add explicit dependencies for androidx.{fragment|activity}
Fixes: E AndroidRuntime: FATAL EXCEPTION: main
    E AndroidRuntime: Process: com.stevesoltys.seedvault, PID: 6688
    E AndroidRuntime: java.lang.NoClassDefFoundError: Failed resolution of:
            Landroidx/fragment/app/FragmentViewModelLazyKt;
Change-Id: I74d9cc78739db8496865439b9dcc2c31dc4b5416
2022-09-02 10:25:06 +03:00
Torsten Grote
fca09ccb9a
Merge pull request #436 from grote/android13-upgrades-minSdk
More work for Android13
2022-08-23 11:56:55 -03:00
Torsten Grote
4e0fab1883
Bump version code and version name
also add changelog entry
2022-08-23 11:44:19 -03:00
Torsten Grote
6ea33632cd
Upgrade more dependencies for Android 13
Now is a good time as we need to thoroughly test everything again anyway.
2022-08-23 11:44:18 -03:00
Torsten Grote
46e19516cd
Add POST_NOTIFICATIONS permission and pre-grant it 2022-08-23 11:44:18 -03:00
Torsten Grote
82f23b7800
Set minSdk to 32 and remove code for old SDKs
We can't go to 33 yet, because roboelectric doesn't support that
2022-08-23 11:44:18 -03:00
Torsten Grote
c856048f8f
Merge pull request #434 from theimpulson/android13
Android13
2022-08-23 10:23:03 -03:00
Aayush Gupta
02af9a27a8 restore: install: Cast any() to Int to avoid oevrload errors
Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
2022-08-23 18:36:42 +05:30
Torsten Grote
d72bee523b Mock ApplicationInfo
as it now calls the native SystemClock.uptimeMillis() method which is hard to mock
2022-08-23 18:30:55 +05:30
Aayush Gupta
65fa49132e settings: AppListRetriever: Switch to lowercase() method
W: 'toLowerCase(Locale): String' is deprecated. Use lowercase() instead.

Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
2022-08-23 18:30:43 +05:30
Aayush Gupta
584a54b127 gradle: Upgrade robolectric and add explicit dependency on hamcrest
Current hamcrest dependency was coming from robolectric but upgrading it
removed it.

Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
2022-08-23 18:30:43 +05:30
Aayush Gupta
dd49a4797e gradle: Bump SDK versions to 33
Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
2022-08-23 14:43:34 +05:30
Aayush Gupta
4b8427821b gradle: Enable java 11 language features
Also unify the style while at it

Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
2022-08-23 14:43:34 +05:30
Aayush Gupta
f0a3acf4fc {seedvault|storage}: Add explicit dependencies for kotlin coroutines
Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
2022-08-23 14:43:34 +05:30
Aayush Gupta
6f81e48dc1 storage: Switch to inWholeMilliseconds property
W: 'toLongMilliseconds(): Long' is deprecated. Use inWholeMilliseconds property instead.

Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
2022-08-23 14:43:34 +05:30
Aayush Gupta
288daadd8b storage: Address experimental time API errors
Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
2022-08-23 14:43:33 +05:30
Aayush Gupta
c48aa73ad0 gradle: Bump kotlin and dependencies version for Android 13
Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
2022-08-23 14:43:33 +05:30
Aayush Gupta
68cef19f28 gradle: Bump to latest stable AGP and gradle versions
Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
2022-08-22 13:55:38 +05:30
Torsten Grote
07bf19b61b
Update README 2022-08-19 09:05:47 -03:00
Torsten Grote
3aa1b9f03d
Merge pull request #422 from t-m-w/do-not-restore-storage-provider
Exclude storage provider from restore
2022-08-15 17:29:01 -03:00
t-m-w
7901aec408 Exclude storage provider from restore and update affected unit tests,
additionally adding a test to ensure the storage provider is excluded.

Otherwise, when the storage provider (i.e. DAVx5 or Nextcloud) is installed,
it will be terminated, and the restoration process will be interrupted.

Change-Id: Ic1be201b673d718b416009ff61f5d975c89b6a62
2022-07-11 16:58:52 -04:00
Torsten Grote
b170634c93 Add missing SVG icon source files 2022-07-09 03:46:26 +05:30
Torsten Grote
b856782d33 [storage] Make backup content selection work better with screen readers 2022-07-08 20:11:38 +05:30
Torsten Grote
49c9425166 Expose app status information to screen readers
This is for backup, restore and re-install status.
2022-07-08 20:11:38 +05:30
José Rebelo
976e898656 Mark background backup notification as ongoing 2022-06-07 03:15:07 +05:30
Michael W
19ed570a4e Tell user about non enabled backup
* Pressing "Backup now" should not just ignore you when it's not actually
  enabled
* Add a toast message telling you it's not enabled

Fixes: #390
Change-Id: I5d698a244652e094b0acfc42cdea017a0af9a20b
2022-06-07 03:14:55 +05:30
Michael W
c97375b294 Seedvault: Fix button on code output
* Missed in the SuW redesign commit

Change-Id: Ie035b77470672248ccc531334cea5a3005fb1e20
2022-06-07 03:14:45 +05:30
Torsten Grote
034ca5aa89
Merge pull request #402 from BadDaemon/android12-redesign
Seedvault: Redesign SUW activities for 12
2022-05-31 11:08:33 -03:00
Michael W
4576c6d332 Seedvault: Redesign SUW activities for 12
* New SetupWizard uses external/setupdesign (sud) and
  external/setupcompat (suc) to achieve the desired looks
* It prevents proper previews when included in any app, though, so
  we better try achieving the same by manually styling the activities
  for 12
* This patch mimics the design by applying styles similar to the ones
  from sud, sometimes reusing parts taken from there

Change-Id: Iccf588e5239aeb00645f97b095910986f32c52d0
2022-05-26 12:35:48 +02:00
Michel Le Bihan
e26081fcfa Translated using Weblate (Polish)
Currently translated at 100.0% (16 of 16 strings)

Translated using Weblate (Polish)

Currently translated at 84.6% (143 of 169 strings)

Co-authored-by: Michel Le Bihan <michel@lebihan.pl>
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/pl/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault_storage/pl/
Translation: CalyxOS/Seedvault
Translation: CalyxOS/Seedvault storage backup
2022-04-29 23:55:05 +05:30
Jeffree Romero
1df679ad8f Translated using Weblate (Spanish)
Currently translated at 100.0% (169 of 169 strings)

Co-authored-by: Jeffree Romero <jeffree.s.romero@gmail.com>
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/es/
Translation: CalyxOS/Seedvault
2022-04-29 23:55:05 +05:30
Егор Ермаков
7dc67a9104 Translated using Weblate (Russian)
Currently translated at 100.0% (169 of 169 strings)

Co-authored-by: Егор Ермаков <eg.ermakov2016@gmail.com>
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/ru/
Translation: CalyxOS/Seedvault
2022-04-29 23:55:05 +05:30
Atrate
8f2b59229e Translated using Weblate (Polish)
Currently translated at 62.5% (10 of 16 strings)

Translated using Weblate (Polish)

Currently translated at 100.0% (1 of 1 strings)

Co-authored-by: Atrate <Atrate@protonmail.com>
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault_contactsbackup/pl/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault_storage/pl/
Translation: CalyxOS/Seedvault contacts backup
Translation: CalyxOS/Seedvault storage backup
2022-04-29 23:55:05 +05:30
Torsten Grote
d598aac81e Clean up system USB storage feature a bit 2022-04-29 23:43:09 +05:30
Torsten Grote
81d5281a94 Save restore storage only when it had backups
Incidentally this gets rid of the need to pass an implementation-specific Uri to the StoragePlugin.
2022-04-29 23:43:09 +05:30
Oliver Scott
d7910a84b4 Save storage unconditionally on location set
The storage plugin cannot find USB backups for secondary users if it is not saved before checking if backups exist
2022-04-29 23:43:09 +05:30
Oliver Scott
dd57828697 Allow secondary user backup to USB
By default, Android exposes USB devices only to the main user.
In order to query, read and write to it, the signature permission INTERACT_ACROSS_USERS_FULL (optional) is granted to create Seedvault's context as the system user.

Issue: calyxos#437
Issue: https://github.com/seedvault-app/seedvault/issues/77
Change-Id: I0b1b4c8c5aeeb226419ff94e15f631ebe1db66df
2022-04-29 23:43:09 +05:30
Nextross
fa93d5dfcc Translated using Weblate (Czech)
Currently translated at 100.0% (16 of 16 strings)

Translated using Weblate (Czech)

Currently translated at 99.4% (168 of 169 strings)

Co-authored-by: Nextross <onlineservices.aminolysis@aleeas.com>
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/cs/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault_storage/cs/
Translation: CalyxOS/Seedvault
Translation: CalyxOS/Seedvault storage backup
2022-03-24 21:18:05 +05:30
Chirayu Desai
c832f71a29 Deleted translation using Weblate (Uyghur)
Deleted translation using Weblate (Uyghur)

Deleted translation using Weblate (Uyghur)

Co-authored-by: Chirayu Desai <chirayudesai1@gmail.com>
2022-03-24 21:18:05 +05:30
Reza Almanda
0d2f51b5e6 Translated using Weblate (Indonesian)
Currently translated at 56.2% (95 of 169 strings)

Co-authored-by: Reza Almanda <rezaalmanda27@gmail.com>
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/id/
Translation: CalyxOS/Seedvault
2022-03-24 21:18:05 +05:30
Micovec
31d31bd6f9 Translated using Weblate (Czech)
Currently translated at 93.7% (15 of 16 strings)

Translated using Weblate (Czech)

Currently translated at 100.0% (1 of 1 strings)

Translated using Weblate (Czech)

Currently translated at 91.1% (154 of 169 strings)

Translated using Weblate (Czech)

Currently translated at 76.9% (130 of 169 strings)

Co-authored-by: Micovec <jiri.vokrinek@email.cz>
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/cs/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault_contactsbackup/cs/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault_storage/cs/
Translation: CalyxOS/Seedvault
Translation: CalyxOS/Seedvault contacts backup
Translation: CalyxOS/Seedvault storage backup
2022-03-24 21:18:05 +05:30
Baptiste H
d5cf2a371a Translated using Weblate (French)
Currently translated at 100.0% (16 of 16 strings)

Translated using Weblate (French)

Currently translated at 100.0% (1 of 1 strings)

Translated using Weblate (French)

Currently translated at 100.0% (169 of 169 strings)

Co-authored-by: Baptiste H <baptiste.huchon@bechamail.fr>
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/fr/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault_contactsbackup/fr/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault_storage/fr/
Translation: CalyxOS/Seedvault
Translation: CalyxOS/Seedvault contacts backup
Translation: CalyxOS/Seedvault storage backup
2022-03-24 21:18:05 +05:30
Yaron Shahrabani
cf6c709616 Translated using Weblate (Hebrew)
Currently translated at 100.0% (16 of 16 strings)

Translated using Weblate (Hebrew)

Currently translated at 100.0% (1 of 1 strings)

Co-authored-by: Yaron Shahrabani <sh.yaron@gmail.com>
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault_contactsbackup/he/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault_storage/he/
Translation: CalyxOS/Seedvault contacts backup
Translation: CalyxOS/Seedvault storage backup
2022-03-24 21:18:05 +05:30
kbci_wcn
4a1aa34eee Translated using Weblate (Catalan)
Currently translated at 100.0% (16 of 16 strings)

Translated using Weblate (Catalan)

Currently translated at 100.0% (169 of 169 strings)

Translated using Weblate (Catalan)

Currently translated at 87.5% (148 of 169 strings)

Translated using Weblate (Catalan)

Currently translated at 80.4% (136 of 169 strings)

Translated using Weblate (Catalan)

Currently translated at 71.0% (120 of 169 strings)

Translated using Weblate (Catalan)

Currently translated at 20.7% (35 of 169 strings)

Translated using Weblate (Catalan)

Currently translated at 15.3% (26 of 169 strings)

Translated using Weblate (Catalan)

Currently translated at 5.9% (10 of 169 strings)

Translated using Weblate (Catalan)

Currently translated at 100.0% (1 of 1 strings)

Translated using Weblate (Catalan)

Currently translated at 4.7% (8 of 169 strings)

Co-authored-by: kbci_wcn <kbci_wcn@aleeas.com>
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/ca/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault_contactsbackup/ca/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault_storage/ca/
Translation: CalyxOS/Seedvault
Translation: CalyxOS/Seedvault contacts backup
Translation: CalyxOS/Seedvault storage backup
2022-03-24 21:18:05 +05:30
Nikita Epifanov
cd71458a5c Translated using Weblate (Russian)
Currently translated at 93.7% (15 of 16 strings)

Translated using Weblate (Russian)

Currently translated at 100.0% (1 of 1 strings)

Translated using Weblate (Russian)

Currently translated at 98.2% (166 of 169 strings)

Co-authored-by: Nikita Epifanov <nikgreens@protonmail.com>
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/ru/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault_contactsbackup/ru/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault_storage/ru/
Translation: CalyxOS/Seedvault
Translation: CalyxOS/Seedvault contacts backup
Translation: CalyxOS/Seedvault storage backup
2022-03-24 21:18:05 +05:30
nzgha
b47f3efa9d Translated using Weblate (Spanish)
Currently translated at 100.0% (16 of 16 strings)

Translated using Weblate (Spanish)

Currently translated at 100.0% (1 of 1 strings)

Co-authored-by: nzgha <nzgha.hw@runbox.com>
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault_contactsbackup/es/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault_storage/es/
Translation: CalyxOS/Seedvault contacts backup
Translation: CalyxOS/Seedvault storage backup
2022-03-24 21:18:05 +05:30
Armand LB
4949a5997a Translated using Weblate (French)
Currently translated at 99.4% (168 of 169 strings)

Translated using Weblate (French)

Currently translated at 97.6% (165 of 169 strings)

Co-authored-by: Armand LB <armandleborgne@protonmail.com>
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/fr/
Translation: CalyxOS/Seedvault
2022-03-24 21:18:05 +05:30
bruh
0c7876a37d Translated using Weblate (Vietnamese)
Currently translated at 100.0% (169 of 169 strings)

Co-authored-by: bruh <quangtrung02hn16@gmail.com>
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/vi/
Translation: CalyxOS/Seedvault
2022-03-24 21:18:05 +05:30
Me0wzz
cb9f9e35ca Translated using Weblate (Korean)
Currently translated at 100.0% (16 of 16 strings)

Translated using Weblate (Korean)

Currently translated at 100.0% (1 of 1 strings)

Translated using Weblate (Korean)

Currently translated at 100.0% (169 of 169 strings)

Translated using Weblate (Korean)

Currently translated at 81.6% (138 of 169 strings)

Co-authored-by: Me0wzz <me0wzz@protonmail.ch>
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/ko/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault_contactsbackup/ko/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault_storage/ko/
Translation: CalyxOS/Seedvault
Translation: CalyxOS/Seedvault contacts backup
Translation: CalyxOS/Seedvault storage backup
2022-03-24 21:18:05 +05:30
nautilusx
4c8896e46f Translated using Weblate (German)
Currently translated at 100.0% (16 of 16 strings)

Translated using Weblate (German)

Currently translated at 100.0% (1 of 1 strings)

Translated using Weblate (German)

Currently translated at 100.0% (169 of 169 strings)

Co-authored-by: nautilusx <translate@disroot.org>
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/de/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault_contactsbackup/de/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault_storage/de/
Translation: CalyxOS/Seedvault
Translation: CalyxOS/Seedvault contacts backup
Translation: CalyxOS/Seedvault storage backup
2022-03-24 21:18:05 +05:30
Gabriel Cardoso
64d30f8849 Translated using Weblate (Portuguese (Brazil))
Currently translated at 98.8% (167 of 169 strings)

Translated using Weblate (Portuguese (Brazil))

Currently translated at 100.0% (16 of 16 strings)

Translated using Weblate (Portuguese (Brazil))

Currently translated at 43.7% (7 of 16 strings)

Translated using Weblate (Portuguese (Brazil))

Currently translated at 100.0% (1 of 1 strings)

Translated using Weblate (Portuguese (Brazil))

Currently translated at 98.8% (167 of 169 strings)

Co-authored-by: Gabriel Cardoso <g.cardoso@mailfence.com>
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/pt_BR/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault_contactsbackup/pt_BR/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault_storage/pt_BR/
Translation: CalyxOS/Seedvault
Translation: CalyxOS/Seedvault contacts backup
Translation: CalyxOS/Seedvault storage backup
2022-03-24 21:18:05 +05:30
Eric
20375444f4 Translated using Weblate (Chinese (Simplified))
Currently translated at 100.0% (169 of 169 strings)

Translated using Weblate (Chinese (Simplified))

Currently translated at 100.0% (1 of 1 strings)

Translated using Weblate (Chinese (Simplified))

Currently translated at 100.0% (169 of 169 strings)

Translated using Weblate (Chinese (Simplified))

Currently translated at 100.0% (169 of 169 strings)

Translated using Weblate (Chinese (Simplified))

Currently translated at 100.0% (164 of 164 strings)

Co-authored-by: Eric <alchemillatruth@purelymail.com>
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/zh_Hans/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault_contactsbackup/zh_Hans/
Translation: CalyxOS/Seedvault
Translation: CalyxOS/Seedvault contacts backup
2022-03-24 21:18:05 +05:30
Óscar Fernández Díaz
ab22e51cfb Translated using Weblate (Spanish)
Currently translated at 100.0% (169 of 169 strings)

Translated using Weblate (Spanish)

Currently translated at 100.0% (164 of 164 strings)

Co-authored-by: Óscar Fernández Díaz <oscfdezdz@tuta.io>
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/es/
Translation: CalyxOS/Seedvault
2022-03-24 21:18:05 +05:30
Oğuz Ersen
ce0e8af4db Translated using Weblate (Turkish)
Currently translated at 100.0% (16 of 16 strings)

Translated using Weblate (Turkish)

Currently translated at 100.0% (1 of 1 strings)

Translated using Weblate (Turkish)

Currently translated at 100.0% (169 of 169 strings)

Translated using Weblate (Turkish)

Currently translated at 100.0% (164 of 164 strings)

Co-authored-by: Oğuz Ersen <oguzersen@protonmail.com>
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/tr/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault_contactsbackup/tr/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault_storage/tr/
Translation: CalyxOS/Seedvault
Translation: CalyxOS/Seedvault contacts backup
Translation: CalyxOS/Seedvault storage backup
2022-03-24 21:18:05 +05:30
Weblate
4c829c6760 Added translation using Weblate (Uyghur)
Added translation using Weblate (Uyghur)

Added translation using Weblate (Uyghur)

Added translation using Weblate (English (India))

Added translation using Weblate (Norwegian Bokmål)

Added translation using Weblate (Serbian (latin))

Added translation using Weblate (Spanish (American))

Added translation using Weblate (French (Canada))

Added translation using Weblate (Chinese (Simplified))

Added translation using Weblate (Chinese (Traditional))

Added translation using Weblate (English (Canada))

Added translation using Weblate (English (Australia))

Added translation using Weblate (Burmese)

Added translation using Weblate (Assamese)

Added translation using Weblate (Tagalog)

Added translation using Weblate (Portuguese (Portugal))

Added translation using Weblate (Uzbek)

Added translation using Weblate (Urdu)

Added translation using Weblate (Kyrgyz)

Added translation using Weblate (Slovenian)

Added translation using Weblate (Sinhala)

Added translation using Weblate (Slovak)

Added translation using Weblate (Khmer (Central))

Added translation using Weblate (Kannada)

Added translation using Weblate (Korean)

Added translation using Weblate (Albanian)

Added translation using Weblate (Serbian)

Added translation using Weblate (Kazakh)

Added translation using Weblate (Georgian)

Added translation using Weblate (Finnish)

Added translation using Weblate (Persian)

Added translation using Weblate (Swedish)

Added translation using Weblate (French)

Added translation using Weblate (Spanish)

Added translation using Weblate (Nepali)

Added translation using Weblate (Dutch)

Added translation using Weblate (Indonesian)

Added translation using Weblate (Azerbaijani)

Added translation using Weblate (Zulu)

Added translation using Weblate (Arabic)

Added translation using Weblate (Italian)

Added translation using Weblate (Amharic)

Added translation using Weblate (Swahili)

Added translation using Weblate (Afrikaans)

Added translation using Weblate (Marathi)

Added translation using Weblate (Malay)

Added translation using Weblate (Polish)

Added translation using Weblate (Macedonian)

Added translation using Weblate (Mongolian)

Added translation using Weblate (Malayalam)

Added translation using Weblate (Hebrew)

Added translation using Weblate (Hindi)

Added translation using Weblate (Hungarian)

Added translation using Weblate (Croatian)

Added translation using Weblate (Armenian)

Added translation using Weblate (English (United Kingdom))

Added translation using Weblate (Icelandic)

Added translation using Weblate (Vietnamese)

Added translation using Weblate (Punjabi)

Added translation using Weblate (Portuguese)

Added translation using Weblate (Czech)

Added translation using Weblate (Catalan)

Added translation using Weblate (Odia)

Added translation using Weblate (Japanese)

Added translation using Weblate (Bosnian)

Added translation using Weblate (Ukrainian)

Added translation using Weblate (Bulgarian)

Added translation using Weblate (Belarusian)

Added translation using Weblate (Bengali)

Added translation using Weblate (Romanian)

Added translation using Weblate (Russian)

Added translation using Weblate (Estonian)

Added translation using Weblate (Basque)

Added translation using Weblate (Danish)

Added translation using Weblate (German)

Added translation using Weblate (Portuguese (Brazil))

Added translation using Weblate (Chinese (Traditional, Hong Kong))

Added translation using Weblate (Tamil)

Added translation using Weblate (Telugu)

Added translation using Weblate (Thai)

Added translation using Weblate (Lithuanian)

Added translation using Weblate (Latvian)

Added translation using Weblate (Turkish)

Added translation using Weblate (Lao)

Added translation using Weblate (Galician)

Added translation using Weblate (Gujarati)

Added translation using Weblate (English (India))

Added translation using Weblate (Norwegian Bokmål)

Added translation using Weblate (Serbian (latin))

Added translation using Weblate (Spanish (American))

Added translation using Weblate (French (Canada))

Added translation using Weblate (Chinese (Simplified))

Added translation using Weblate (Chinese (Traditional))

Added translation using Weblate (English (Canada))

Added translation using Weblate (English (Australia))

Added translation using Weblate (Burmese)

Added translation using Weblate (Assamese)

Added translation using Weblate (Tagalog)

Added translation using Weblate (Portuguese (Portugal))

Added translation using Weblate (Uzbek)

Added translation using Weblate (Urdu)

Added translation using Weblate (Kyrgyz)

Added translation using Weblate (Slovenian)

Added translation using Weblate (Sinhala)

Added translation using Weblate (Slovak)

Added translation using Weblate (Khmer (Central))

Added translation using Weblate (Kannada)

Added translation using Weblate (Korean)

Added translation using Weblate (Albanian)

Added translation using Weblate (Serbian)

Added translation using Weblate (Kazakh)

Added translation using Weblate (Georgian)

Added translation using Weblate (Finnish)

Added translation using Weblate (Persian)

Added translation using Weblate (Swedish)

Added translation using Weblate (French)

Added translation using Weblate (Spanish)

Added translation using Weblate (Nepali)

Added translation using Weblate (Dutch)

Added translation using Weblate (Indonesian)

Added translation using Weblate (Azerbaijani)

Added translation using Weblate (Zulu)

Added translation using Weblate (Arabic)

Added translation using Weblate (Italian)

Added translation using Weblate (Amharic)

Added translation using Weblate (Swahili)

Added translation using Weblate (Afrikaans)

Added translation using Weblate (Marathi)

Added translation using Weblate (Malay)

Added translation using Weblate (Polish)

Added translation using Weblate (Macedonian)

Added translation using Weblate (Mongolian)

Added translation using Weblate (Malayalam)

Added translation using Weblate (Hebrew)

Added translation using Weblate (Hindi)

Added translation using Weblate (Hungarian)

Added translation using Weblate (Croatian)

Added translation using Weblate (Armenian)

Added translation using Weblate (English (United Kingdom))

Added translation using Weblate (Icelandic)

Added translation using Weblate (Vietnamese)

Added translation using Weblate (Punjabi)

Added translation using Weblate (Portuguese)

Added translation using Weblate (Czech)

Added translation using Weblate (Catalan)

Added translation using Weblate (Odia)

Added translation using Weblate (Japanese)

Added translation using Weblate (Bosnian)

Added translation using Weblate (Ukrainian)

Added translation using Weblate (Bulgarian)

Added translation using Weblate (Belarusian)

Added translation using Weblate (Bengali)

Added translation using Weblate (Romanian)

Added translation using Weblate (Russian)

Added translation using Weblate (Estonian)

Added translation using Weblate (Basque)

Added translation using Weblate (Danish)

Added translation using Weblate (German)

Added translation using Weblate (Portuguese (Brazil))

Added translation using Weblate (Chinese (Traditional, Hong Kong))

Added translation using Weblate (Tamil)

Added translation using Weblate (Telugu)

Added translation using Weblate (Thai)

Added translation using Weblate (Lithuanian)

Added translation using Weblate (Latvian)

Added translation using Weblate (Turkish)

Added translation using Weblate (Lao)

Added translation using Weblate (Galician)

Added translation using Weblate (Gujarati)

Co-authored-by: Weblate <noreply@weblate.org>
2022-03-24 21:18:05 +05:30
Yaron Shahrabani
e69a7b3f0d Translated using Weblate (Hebrew)
Currently translated at 100.0% (169 of 169 strings)

Translated using Weblate (Hebrew)

Currently translated at 100.0% (169 of 169 strings)

Translated using Weblate (Hebrew)

Currently translated at 100.0% (164 of 164 strings)

Translated using Weblate (Hebrew)

Currently translated at 95.7% (157 of 164 strings)

Co-authored-by: Yaron Shahrabani <sh.yaron@gmail.com>
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/he/
Translation: CalyxOS/Seedvault
2022-03-24 21:18:05 +05:30
Michael Bestas
c06cab77cc Translated using Weblate (Greek)
Currently translated at 100.0% (169 of 169 strings)

Translated using Weblate (Greek)

Currently translated at 100.0% (16 of 16 strings)

Translated using Weblate (Greek)

Currently translated at 100.0% (164 of 164 strings)

Added translation using Weblate (Greek)

Translated using Weblate (Greek)

Currently translated at 100.0% (1 of 1 strings)

Translated using Weblate (Greek)

Currently translated at 100.0% (164 of 164 strings)

Added translation using Weblate (Greek)

Translated using Weblate (Greek)

Currently translated at 99.3% (163 of 164 strings)

Co-authored-by: Michael Bestas <mkbestas@gmail.com>
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/el/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault_contactsbackup/el/
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault_storage/el/
Translation: CalyxOS/Seedvault
Translation: CalyxOS/Seedvault contacts backup
Translation: CalyxOS/Seedvault storage backup
2022-03-24 21:18:05 +05:30
Michael Bestas
a5ea02d988 storage: Ignore missing translations
Similar to 22f5036cf5 and 55909ce305

Change-Id: Iae3e97c434c79b8ea2bba943fc0464e5699fe9c7
2022-03-07 20:07:35 +05:30
Michael Bestas
22f5036cf5 contactsbackup: Ignore missing translations
Similar to 55909ce305

Change-Id: Ifdf80c2d202f24120776b21a4fe9d63022b3cae9
2022-03-07 19:37:44 +05:30
Michael Bestas
1d0aa434c7 Remove usages of jcenter() Maven repository
This repository is deprecated and it will be shut down in the future.
See http://developer.android.com/r/tools/jcenter-end-of-service for more information.

JCenter will be able to resolve dependencies until February 1, 2022 without changes.
After that date, there are no guarantees that you will be able to build your software
if you continue to use JCenter.
See https://blog.gradle.org/jcenter-shutdown for more information.

Change-Id: I9bc875e0b9380a254d91481860f5efb4281c0840
2022-01-14 00:49:48 +05:30
Michael Bestas
06417651bc Bump org.jetbrains.dokka version to remove jcenter dependency
Change-Id: Icf05e7a51221a7b5af58c0c45d5a2c14d9fb65c3
2022-01-14 00:49:48 +05:30
Torsten Grote
17a83eaab3 Always add a storage option placeholder for DavX5 2022-01-13 06:32:05 +05:30
Torsten Grote
4ee7605b50 Refactor StorageRoots to be more generic to prepare for non-SAF storage plugins
and to make it easier to add placeholders for storage options
2022-01-13 06:32:05 +05:30
Michael Bestas
b1ca70193c Fix storage restore progress string 2022-01-12 04:35:09 +05:30
Chirayu Desai
2b4bb1cb4f Deleted translation using Weblate (Uyghur) 2022-01-12 03:50:48 +05:30
Torsten Grote
129f8d90e5
Merge pull request #358 from chirayudesai/suw-redesign-1
Don't hide navigation bar in setup wizard
2022-01-04 17:29:28 -03:00
Michael Bestas
08610e1332 Don't hide navigation bar in setup wizard
Also:
Remove back button from recovery code input page
Convert root back button to skip button

Change-Id: I0bca13b53ac3898f2ab3b8503aaf7d2bc51a983a
2022-01-05 01:45:01 +05:30
Giovanni Ricca
efaeaa56ad Translated using Weblate (Italian)
Currently translated at 72.5% (116 of 160 strings)

Translation: CalyxOS/Seedvault
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/it/
2022-01-05 01:40:46 +05:30
Chirayu Desai
4795a88762 Deleted translation using Weblate (Spanish (Argentina)) 2022-01-05 01:40:46 +05:30
Michael Bestas
6e6695fea1 Remove unused translations
* Fixes lint checks after 0f241f7d25

Change-Id: I578e5bc68e6c0a1cedc8da8c547d1813e212d072
2022-01-05 01:40:46 +05:30
ssantos
302740f59d Translated using Weblate (Portuguese)
Currently translated at 100.0% (160 of 160 strings)

Translation: CalyxOS/Seedvault
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/pt/
2022-01-05 01:40:46 +05:30
fem
06ef8fc124 Translated using Weblate (Japanese)
Currently translated at 99.3% (159 of 160 strings)

Translation: CalyxOS/Seedvault
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/ja/
2022-01-05 01:40:46 +05:30
Gabriel Cardoso
d4da47634f Translated using Weblate (Portuguese (Brazil))
Currently translated at 100.0% (160 of 160 strings)

Translation: CalyxOS/Seedvault
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/pt_BR/
2022-01-05 01:40:46 +05:30
御守りのいちか
e00b899055 Translated using Weblate (Chinese (Traditional))
Currently translated at 21.8% (35 of 160 strings)

Translation: CalyxOS/Seedvault
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/zh_Hant/
2022-01-05 01:40:46 +05:30
Gabriel Cardoso
8bcb1e8692 Translated using Weblate (Portuguese (Brazil))
Currently translated at 92.5% (148 of 160 strings)

Translation: CalyxOS/Seedvault
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/pt_BR/
2022-01-05 01:40:46 +05:30
Ilya
723b958ba4 Translated using Weblate (Russian)
Currently translated at 98.7% (158 of 160 strings)

Translation: CalyxOS/Seedvault
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/ru/
Change-Id: I218e6e24e5c72fb640865c8615ff38373681196d
2022-01-05 01:40:46 +05:30
Reza Almanda
eb31b2444a Translated using Weblate (Indonesian)
Currently translated at 52.5% (84 of 160 strings)

Translation: CalyxOS/Seedvault
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/id/
2022-01-05 01:40:46 +05:30
Milo Ivir
c61c88f1df Translated using Weblate (Croatian)
Currently translated at 100.0% (160 of 160 strings)

Translation: CalyxOS/Seedvault
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/hr/
Change-Id: I4073f6c141d5b448003b60d0a818ed4bc6306177
2022-01-05 01:40:46 +05:30
Armand LB
31d2d9c46b Translated using Weblate (French)
Currently translated at 100.0% (160 of 160 strings)

Translation: CalyxOS/Seedvault
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/fr/
Change-Id: I83217e2b06c0dfa38eeca6caa8601138a24a3582
2022-01-05 01:40:46 +05:30
Yaron Shahrabani
25a416bcfc Translated using Weblate (Hebrew)
Currently translated at 97.5% (156 of 160 strings)

Translation: CalyxOS/Seedvault
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/he/
2022-01-05 01:40:46 +05:30
Nekromanser
95aa1b28f5 Translated using Weblate (Finnish)
Currently translated at 100.0% (160 of 160 strings)

Translation: CalyxOS/Seedvault
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/fi/
2022-01-05 01:40:46 +05:30
Weblate
2a7284e8ea Added translation using Weblate (Uyghur) 2022-01-05 01:40:46 +05:30
Weblate
975421198d Added translation using Weblate (Spanish (Argentina)) 2022-01-05 01:40:46 +05:30
Nekromanser
8cc88ac993 Translated using Weblate (Finnish)
Currently translated at 85.0% (136 of 160 strings)

Translation: CalyxOS/Seedvault
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/fi/
2022-01-05 01:40:46 +05:30
Alexandre Brochand
873a095d8f Translated using Weblate (French)
Currently translated at 91.2% (146 of 160 strings)

Translation: CalyxOS/Seedvault
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/fr/
2022-01-05 01:40:46 +05:30
bruh
61567ed83a Translated using Weblate (Vietnamese)
Currently translated at 100.0% (160 of 160 strings)

Translation: CalyxOS/Seedvault
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/vi/
Change-Id: I8d7115c34f86e960c8e2cf168f3c3144214eaf71
2022-01-05 01:40:46 +05:30
Óscar Fernández Díaz
457e287c67 Translated using Weblate (Spanish)
Currently translated at 100.0% (160 of 160 strings)

Translation: CalyxOS/Seedvault
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/es/
Change-Id: Ib2ef827f26476597d478f8deca5673a2dbac4d59
2022-01-05 01:40:46 +05:30
Gediminas Murauskas
43f2c7a751 Translated using Weblate (Lithuanian)
Currently translated at 100.0% (160 of 160 strings)

Translation: CalyxOS/Seedvault
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/lt/
Change-Id: Iea1fe96abe6845c361171ad7d775922c9d0cc782
2022-01-05 01:40:46 +05:30
Yaron Shahrabani
a026af10b9 Translated using Weblate (Hebrew)
Currently translated at 69.3% (111 of 160 strings)

Translation: CalyxOS/Seedvault
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/he/
2022-01-05 01:40:46 +05:30
Eric
9a1f5e3864 Translated using Weblate (Chinese (Simplified))
Currently translated at 100.0% (160 of 160 strings)

Co-authored-by: Eric <spice2wolf@gmail.com>
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/zh_Hans/
Translation: CalyxOS/Seedvault
Change-Id: I61376609ee1b59f103fa469790127ae36c4fc47a
2022-01-05 01:40:46 +05:30
nautilusx
51293688c9 Translated using Weblate (German)
Currently translated at 100.0% (160 of 160 strings)

Co-authored-by: nautilusx <translate@disroot.org>
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/de/
Translation: CalyxOS/Seedvault
Change-Id: I791df0a0ceac12eb492b7837be841bc613f822e0
2022-01-05 01:40:46 +05:30
Oğuz Ersen
3210e79305 Translated using Weblate (Turkish)
Currently translated at 100.0% (160 of 160 strings)

Co-authored-by: Oğuz Ersen <oguzersen@protonmail.com>
Translate-URL: https://hosted.weblate.org/projects/calyxos/seedvault/tr/
Translation: CalyxOS/Seedvault
Change-Id: I509a1c362e1e96e5ac4967e00071b286c675178d
2022-01-05 01:40:46 +05:30
Torsten Grote
7d4fd105bf Fix finishing RequireProvisioningActivity when provisioning is aborted
On Android 11 this worked fine, but on Android 12 onStart() happens before activity results get delivered. We finish the activity when receiving a cancelled result. However, when onStart() gets called before we know the result, we relaunch an activity required for provisioning again instead of finishing.
2022-01-04 21:46:42 +05:30
Torsten Grote
a717ebaf9c
Merge pull request #323 from chirayudesai/12
Android 12 - 12-3.0 - new backup format!
2021-12-15 16:10:43 -03:00
Torsten Grote
46da90b100
Merge pull request #343 from mikeNG/system-ext-move
Move Seedvault to /system_ext partition
2021-12-15 16:09:40 -03:00
Torsten Grote
27b45875d7
Merge pull request #341 from grote/dav-x5
Allow DAVx5 DocumentsProvider by default
2021-12-15 16:09:18 -03:00
Michael Bestas
dfec39ee05
Move Seedvault to /system_ext partition
Change-Id: I5a1d33dec45ade9a30925b471652878bfa39404f
2021-11-24 20:18:35 +02:00
Torsten Grote
0746af4304
Allow DAVx5 DocumentsProvider by default 2021-11-12 14:34:00 -03:00
Chirayu Desai
e972956929 Android 12 - 12-3.0
* Bump version following versioning scheme
* 3.0 now following new backup format
* Add initial entry to changelog

Change-Id: Ifca1b3feac0f510890450a1999b42897894d58ee
2021-10-13 18:06:30 +05:30
Torsten Grote
b0c6eeb9f7 Clean up stuck notifications when service gets killed 2021-10-13 17:16:16 +05:30
Torsten Grote
c7880b8a8b Don't crash when no store app is installed 2021-10-13 16:25:41 +05:30
Torsten Grote
c5a295d31c Allow storage backups to launch foreground service from background 2021-10-13 16:25:41 +05:30
Torsten Grote
b184f208c4 Show storage backup notification immediately 2021-10-13 16:25:41 +05:30
Torsten Grote
97398f1c5c Build build storage backup lib within AOSP
This removes the AAR binary from the repo as it isn't needed anymore. Also room schema migrations will need to be one manually in the future as schema export doesn't seem to work in AOSP.
2021-10-13 16:25:41 +05:30
Torsten Grote
5662409ef5 Fix icon colors 2021-10-13 16:25:41 +05:30
Torsten Grote
75d4c7d05c Don't use setUnlockedDeviceRequired() on the backup key
as importing it with Android 12 GSI fails. This key is only used to restore old backups anyway and the new one doesn't use this restriction.
2021-10-13 16:25:41 +05:30
Torsten Grote
579919d5e7 Code style and lint after Android 12 version bumps 2021-10-13 16:25:41 +05:30
Torsten Grote
e80d89f0a2 Use our transport flags when creating RestoreSets
This hopefully prevents apps skipping restore that require end-to-end encrypted backup transports.

3762670bb7
2021-10-13 16:25:41 +05:30
Torsten Grote
7f4b565d2a First version bumps for Android 12 2021-10-13 16:25:41 +05:30
Torsten Grote
b029b0b029 Improve behavior of @pm@ backups when we can't do backups
Before, we were faking a backup and just returned true, but remembering that next time, we need to do a fresh non-incremental @pm@ backup.
Now, we backup to local cache, but don't upload it. On next run, when we can do backups again, we will upload the updated cache. This simplifies things and reduces the special logic required.
2021-10-13 16:15:20 +05:30
Torsten Grote
36c35d6f98 Force backup initialization when we have no cached metadata
as it can happen after clearing app data
2021-10-13 16:15:20 +05:30
Torsten Grote
c59a006a00 Remove @pm@ optimization from BackupNotificationManager
as it shouldn't be needed anymore
2021-10-13 16:15:20 +05:30
Torsten Grote
b8b6882484 Don't try to clear data of NO_DATA system apps
This speeds up the backup quite a bit since there's many such apps
2021-10-13 16:15:20 +05:30
Torsten Grote
79777a7b6f Close K/V DB after restoring records
also don't log stack trace when not finding backup type
2021-10-13 16:15:20 +05:30
Torsten Grote
ef5d1c3bc8 Port auto restore optimization from legacy v0 code to new v1 code 2021-10-13 16:15:20 +05:30
Torsten Grote
3c5e4120c7 Refactor Storage Plugin API 2021-10-13 16:15:20 +05:30
Torsten Grote
50066f0317 Let ApkBackup and ApkRestore use the new storage plugin API 2021-10-13 16:15:20 +05:30
Torsten Grote
183e34afd2 Remove legacy backup plugin code 2021-10-13 16:15:20 +05:30
Torsten Grote
1885021c1c Move backup of APKs of opt-out apps to after uploading @pm@ DB 2021-10-13 16:15:20 +05:30
Torsten Grote
a0f3c6b45f K/V restore using single file 2021-10-13 16:15:20 +05:30
Torsten Grote
0c915e5eb8 K/V backup using single file
Tests are still broken until restore has also been implemented with single file approach
2021-10-13 16:15:20 +05:30
Torsten Grote
23bb385190 Use new storage API for full restore 2021-10-13 16:15:20 +05:30
Torsten Grote
674568ca11 Use new storage API for full backups 2021-10-13 16:15:20 +05:30
Torsten Grote
4bdaaa0ce9 Make RestoreCoordinator use the new storage API with salt and backup type
This breaks restores until all the other required changed have been implemented.
2021-10-13 16:15:20 +05:30
Torsten Grote
75cf014e5d Add crypto method to get salted names for package data and APKs
This will only hide installed apps from naive attackers as the APKs are still not encrypted and even then other attacks would be possible.

However, it allows us to simplify our storage plugin API.
2021-10-13 16:15:20 +05:30
Torsten Grote
793663acb5 Add salt and backup type to metadata 2021-10-13 16:15:20 +05:30
Torsten Grote
39cb0c6443 Factor getting secure random bytes into Crypto interface 2021-10-13 16:15:20 +05:30
Torsten Grote
a77d927624 Remove deprecated methods from BackupPlugin 2021-10-13 16:15:20 +05:30
Torsten Grote
db4103e752 Move code to get available backups from RestorePlugin to BackupPlugin 2021-10-13 16:15:20 +05:30
Torsten Grote
5d1e3debd1 Define new and simpler BackupPlugin API
leaving the old one in place still
2021-10-13 16:15:20 +05:30
Torsten Grote
2932af463c Check version of backup files against expected version from metadata
and throw security exception if it does not match
2021-10-13 16:15:20 +05:30
Torsten Grote
5523e57fe7 Add current metadata to RestoreCoordinator state
so we know which backup version we need to expect during restore
2021-10-13 16:15:20 +05:30
Torsten Grote
bcb245531c Refactor fetching of restorable backups
so that we don't go through the BackupManager API, but use RestoreCoordinator directly
2021-10-13 16:15:20 +05:30
Torsten Grote
aeafc80bb9 Clean up after moving all backup code to new v1 version 2021-10-13 16:15:20 +05:30
Torsten Grote
f4dc776ed3 Do full backups with new version 1 with new crypto
Restoring still supports version 0 with old crypto
2021-10-13 16:15:20 +05:30
Torsten Grote
0c3ea7679b Do K/V backup with new version 1 with new crypto
Restoring still supports version 0 with old crypto
2021-10-13 16:15:20 +05:30
Torsten Grote
3ffb79b04f Write metadata with new version 1
Reading still supports version 0
2021-10-13 16:15:20 +05:30
Torsten Grote
0f241f7d25 Ensure that we have the main key for v1 crypto
We ask the user to generate a new key, because actively asking for the old one is training bad security habits, but technically verifying the old key will also work.
2021-10-13 16:15:20 +05:30
Torsten Grote
7dceb98670 Add test for decrypting and reading version 0 metadata 2021-10-13 16:15:20 +05:30
Torsten Grote
b707d7f9d0 Add test for full and k/v restore of version 0 backups 2021-10-13 16:15:20 +05:30
Michael Bestas
1cae6dc60e Bump version to 11-2.3
Change-Id: I792a1b1039f2ffcf23301334914b9c1fc75244ef
2021-10-05 01:34:35 +05:30
Michael Bestas
bfdf69c2f0 Switch all translations references to github.com/seedvault-app
Change-Id: I400b831c64ca72aa07940e323885595e864b2745
2021-10-05 01:34:35 +05:30
Michael Bestas
dce3ad244d Fix translations after replacing novacrypt BIP39 library
Change-Id: Ie8fe00a8d870374ce86c3766307f954dc9d259ba
2021-10-05 01:34:35 +05:30
836 changed files with 35257 additions and 10901 deletions

66
.cirrus.yml Normal file
View file

@ -0,0 +1,66 @@
container:
image: ghcr.io/cirruslabs/android-sdk:34
kvm: true
cpu: 8
memory: 16G
instrumentation_tests_task:
name: "Cirrus CI Instrumentation Tests"
start_avd_background_script:
sdkmanager --install "system-images;android-34;default;x86_64" "emulator";
echo no | avdmanager create avd -n seedvault -k "system-images;android-34;default;x86_64";
$ANDROID_HOME/emulator/emulator
-avd seedvault
-no-audio
-no-boot-anim
-gpu swiftshader_indirect
-no-snapshot
-no-window
-writable-system;
provision_avd_background_script:
wget https://github.com/seedvault-app/seedvault-test-data/releases/download/3/backup.tar.gz;
adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done;';
adb root;
sleep 5;
adb remount;
adb reboot;
adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done;';
adb root;
sleep 5;
adb remount;
sleep 5;
assemble_script:
./gradlew :app:assembleRelease :contacts:assembleRelease assembleAndroidTest
install_app_script:
timeout 180s bash -c 'while [[ -z $(adb shell mount | grep "/system " | grep "(rw,") ]]; do sleep 1; done;';
adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done;';
adb shell mkdir -p /sdcard/seedvault_baseline;
adb push backup.tar.gz /sdcard/seedvault_baseline/backup.tar.gz;
adb shell tar xzf /sdcard/seedvault_baseline/backup.tar.gz --directory=/sdcard/seedvault_baseline;
adb shell mkdir -p /system/priv-app/Seedvault;
adb push app/build/outputs/apk/release/app-release.apk /system/priv-app/Seedvault/Seedvault.apk;
adb push permissions_com.stevesoltys.seedvault.xml /system/etc/permissions/privapp-permissions-seedvault.xml;
adb push allowlist_com.stevesoltys.seedvault.xml /system/etc/sysconfig/allowlist-seedvault.xml;
adb shell mkdir -p /system/priv-app/ContactsBackup;
adb push contactsbackup/build/outputs/apk/release/contactsbackup-release.apk /system/priv-app/ContactsBackup/contactsbackup.apk;
adb push contactsbackup/default-permissions_org.calyxos.backup.contacts.xml /system/etc/default-permissions/default-permissions_org.calyxos.backup.contacts.xml;
adb shell bmgr enable true;
adb reboot;
adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done;';
adb shell bmgr transport com.stevesoltys.seedvault.transport.ConfigurableBackupTransport;
adb reboot;
adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done;';
run_large_tests_script: ./gradlew -Pandroid.testInstrumentationRunnerArguments.size=large :app:connectedAndroidTest
run_other_tests_script: ./gradlew -Pandroid.testInstrumentationRunnerArguments.notAnnotation=androidx.test.filters.LargeTest connectedAndroidTest
always:
pull_screenshots_script:
adb pull /sdcard/seedvault_test_results
screenshots_artifacts:
path: "seedvault_test_results/**/*.mp4"
logcat_artifacts:
path: "seedvault_test_results/**/*.log"

97
.github/scripts/build_aosp.sh vendored Executable file
View file

@ -0,0 +1,97 @@
#!/usr/bin/env bash
#
# SPDX-FileCopyrightText: 2023 The Calyx Institute
# SPDX-License-Identifier: Apache-2.0
#
export DEBIAN_FRONTEND=noninteractive
apt-get update
apt-get install -y git-core gnupg flex bison build-essential zip curl zlib1g-dev \
libc6-dev-i386 libncurses5 x11proto-core-dev libx11-dev lib32z1-dev libgl1-mesa-dev \
libxml2-utils xsltproc unzip fontconfig python3 npm pip e2fsprogs python3-protobuf \
fonts-dejavu diffutils rsync ccache
npm install --global yarn
mkdir -p ~/bin
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo
ln -s /usr/bin/python3 /usr/bin/python
export PATH=~/bin:$PATH
set -e
retry() {
set +e
local max_attempts=${ATTEMPTS-5}
local timeout=${TIMEOUT-1}
local attempt=0
local exitCode=0
while [[ $attempt < $max_attempts ]]
do
"$@"
exitCode=$?
if [[ $exitCode == 0 ]]
then
break
fi
echo "Failure! Retrying ($*) in $timeout.."
sleep "${timeout}"
attempt=$(( attempt + 1 ))
timeout=$(( timeout * 2 ))
done
if [[ $exitCode != 0 ]]
then
echo "Failed too many times! ($*)"
fi
set -e
return $exitCode
}
DEVICE=$1
RELEASE=$2
TARGET=$3
BRANCH=$4
git config --global user.email "seedvault@example.com"
git config --global user.name "Seedvault CI"
retry curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo
mkdir -p /aosp
cd /aosp
retry yes | repo init -u https://android.googlesource.com/platform/manifest -b "$BRANCH" --depth=1
mkdir -p .repo/local_manifests
cat << EOF > .repo/local_manifests/seedvault.xml
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<remote name="seedvault"
fetch="https://github.com/$CIRRUS_REPO_OWNER" />
<project name="seedvault" path="external/seedvault"
revision="$CIRRUS_CHANGE_IN_REPO" remote="$CIRRUS_REPO_NAME" />
</manifest>
EOF
retry repo sync -c -j8 --fail-fast --force-sync
# Cirrus CI seems to (possibly) reschedule tasks that aren't sending out logs for a while?
while true; do echo "Still building..."; sleep 30; done &
source build/envsetup.sh
lunch $DEVICE-$RELEASE-$TARGET
m -j1 nothing
m -j2 Seedvault
mv /aosp/out/target/product/generic_arm64/system/system_ext/priv-app/Seedvault/Seedvault.apk "$CIRRUS_WORKING_DIR"

31
.github/scripts/run_tests.sh vendored Executable file
View file

@ -0,0 +1,31 @@
#
# SPDX-FileCopyrightText: 2023 The Calyx Institute
# SPDX-License-Identifier: Apache-2.0
#
echo "Disable auto-restore"
adb shell bmgr autorestore false
echo "Installing Seedvault app..."
./gradlew --stacktrace :app:installDebugAndroidTest
sleep 60
large_test_exit_code=0
./gradlew --stacktrace -Pinstrumented_test_size=large :app:connectedAndroidTest || large_test_exit_code=$?
adb pull /sdcard/seedvault_test_results
if [ "$large_test_exit_code" -ne 0 ]; then
echo 'Large tests failed.'
exit 1
fi
medium_test_exit_code=0
./gradlew --stacktrace -Pinstrumented_test_size=medium :app:connectedAndroidTest || medium_test_exit_code=$?
if [ "$medium_test_exit_code" -ne 0 ]; then
echo 'Medium tests failed.'
exit 1
fi
exit 0

61
.github/workflows/build.yml vendored Normal file
View file

@ -0,0 +1,61 @@
name: Build
on: [ push, pull_request ]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
permissions:
contents: read
actions: read
checks: write
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout the code
uses: actions/checkout@v3
- name: Android build cache
uses: actions/cache@v3
with:
path: |
~/.android/build-cache
key: ${{ runner.os }}-android
restore-keys: ${{ runner.os }}-android
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'corretto'
java-version: 17
cache: 'gradle'
- name: Validate Gradle Wrapper
uses: gradle/actions/wrapper-validation@v3
- name: Build
env:
NEXTCLOUD_URL: ${{ vars.NEXTCLOUD_URL }}
NEXTCLOUD_USER: ${{ secrets.NEXTCLOUD_USER }}
NEXTCLOUD_PASS: ${{ secrets.NEXTCLOUD_PASS }}
run: ./gradlew compileDebugAndroidTestSources check assemble ktlintCheck
- name: Upload APKs
uses: actions/upload-artifact@v3
with:
name: seedvault-${{ github.sha }}-apks
path: |
app/build/outputs/apk/debug/app-debug.apk
contactsbackup/build/outputs/apk/debug/contactsbackup-debug.apk
storage/demo/build/outputs/apk/debug/demo-debug.apk
- name: Publish Test Report
uses: mikepenz/action-junit-report@v4
if: success() || failure()
with:
report_paths: '**/build/test-results/**/TEST-*.xml'

View file

@ -1,35 +0,0 @@
name: Build
on: [push, pull_request]
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Gradle dependency cache
uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
restore-keys: ${{ runner.os }}-gradle-
- name: Android build cache
uses: actions/cache@v2
with:
path: |
~/.android/build-cache
key: ${{ runner.os }}-android
restore-keys: ${{ runner.os }}-android
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: Build
run: ./gradlew compileDebugAndroidTestSources check assemble ktlintCheck

62
.github/workflows/test.yml vendored Normal file
View file

@ -0,0 +1,62 @@
name: Run instrumentation tests
on:
push:
branches:
- android*
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
instrumentation_tests:
runs-on: macos-12
if: github.repository == 'seedvault-app/seedvault'
timeout-minutes: 80
strategy:
fail-fast: false
matrix:
android_target: [ 34 ]
emulator_type: [ aosp_atd ]
steps:
- name: Checkout Code
uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: '17'
cache: 'gradle'
- name: Build Release APK
run: ./gradlew :app:assembleRelease
- name: Assemble tests
run: ./gradlew :app:assembleAndroidTest
- name: Run tests
uses: Wandalen/wretry.action@v1.3.0
with:
attempt_limit: 1
action: reactivecircus/android-emulator-runner@v2
with: |
api-level: ${{ matrix.android_target }}
target: ${{ matrix.emulator_type }}
arch: x86_64
force-avd-creation: true
emulator-options: -cores 2 -writable-system -no-snapshot-load -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disk-size: '14G'
sdcard-path-or-size: '4096M'
disable-animations: true
script: |
./app/development/scripts/provision_emulator.sh "test" "system-images;android-${{ matrix.android_target }};${{ matrix.emulator_type }};x86_64"
./.github/scripts/run_tests.sh
- name: Upload test results
if: always()
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.emulator_type }}-${{ matrix.android_target }}-results
path: seedvault_test_results/**/*

6
.gitignore vendored
View file

@ -6,12 +6,18 @@ hs_err_pid*
## Intellij
out/
build/
storage/build/
contactsbackup/build/
/lib/
.idea/*
!.idea/runConfigurations*
!.idea/inspectionProfiles*
!.idea/codeStyles*
!.idea/copyright*
!.idea/dictionaries*
!.idea/scopes*
!.idea/.name
*.ipr
*.iws
*.iml

1
.idea/.name Normal file
View file

@ -0,0 +1 @@
Seedvault

View file

@ -1,11 +1,7 @@
<component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173">
<JetCodeStyleSettings>
<option name="PACKAGES_TO_USE_STAR_IMPORTS">
<value />
</option>
<option name="NAME_COUNT_TO_USE_STAR_IMPORT" value="2147483647" />
<option name="NAME_COUNT_TO_USE_STAR_IMPORT_FOR_MEMBERS" value="2147483647" />
<option name="LINE_BREAK_AFTER_MULTILINE_WHEN_ENTRY" value="false" />
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
</JetCodeStyleSettings>
<codeStyleSettings language="XML">

View file

@ -0,0 +1,6 @@
<component name="CopyrightManager">
<copyright>
<option name="notice" value="SPDX-FileCopyrightText: &amp;#36;today.year The Calyx Institute&#10;SPDX-License-Identifier: Apache-2.0" />
<option name="myName" value="Apache-2.0" />
</copyright>
</component>

View file

@ -0,0 +1,13 @@
<component name="CopyrightManager">
<settings default="Apache-2.0">
<module2copyright>
<element module="Kotlin Files" copyright="Apache-2.0" />
<element module="XML Files" copyright="Apache-2.0" />
</module2copyright>
<LanguageOptions name="XML">
<option name="fileTypeOverride" value="3" />
<option name="addBlankAfter" value="false" />
<option name="prefixLines" value="false" />
</LanguageOptions>
</settings>
</component>

View file

@ -3,9 +3,11 @@
<words>
<w>apk</w>
<w>chunker</w>
<w>davx</w>
<w>ejectable</w>
<w>hasher</w>
<w>hkdf</w>
<w>launchable</w>
<w>restorable</w>
<w>seedvault</w>
<w>snowden</w>

View file

@ -1,13 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RunConfigurationProducerService">
<option name="ignoredProducers">
<set>
<option value="com.android.tools.idea.compose.preview.runconfiguration.ComposePreviewRunConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
</set>
</option>
</component>
</project>

View file

@ -1,6 +1,6 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Instrumentation tests: app" type="AndroidTestRunConfigurationType" factoryName="Android Instrumented Tests" singleton="true">
<module name="seedvault.app" />
<module name="seedvault.app.androidTest" />
<option name="TESTING_TYPE" value="0" />
<option name="METHOD_NAME" value="" />
<option name="CLASS_NAME" value="" />
@ -8,10 +8,12 @@
<option name="INSTRUMENTATION_RUNNER_CLASS" value="" />
<option name="EXTRA_OPTIONS" value="-e notAnnotation androidx.test.filters.LargeTest" />
<option name="INCLUDE_GRADLE_EXTRA_OPTIONS" value="true" />
<option name="RETENTION_ENABLED" value="No" />
<option name="RETENTION_MAX_SNAPSHOTS" value="2" />
<option name="RETENTION_COMPRESS_SNAPSHOTS" value="false" />
<option name="CLEAR_LOGCAT" value="false" />
<option name="SHOW_LOGCAT_AUTOMATICALLY" value="false" />
<option name="SKIP_NOOP_APK_INSTALLATIONS" value="true" />
<option name="FORCE_STOP_RUNNING_APP" value="true" />
<option name="INSPECTION_WITHOUT_ACTIVITY_RESTART" value="false" />
<option name="TARGET_SELECTION_MODE" value="DEVICE_AND_SNAPSHOT_COMBO_BOX" />
<option name="DEBUGGER_TYPE" value="Auto" />
<Auto>
@ -40,7 +42,7 @@
<option name="ADVANCED_PROFILING_ENABLED" value="false" />
<option name="STARTUP_PROFILING_ENABLED" value="false" />
<option name="STARTUP_CPU_PROFILING_ENABLED" value="false" />
<option name="STARTUP_CPU_PROFILING_CONFIGURATION_NAME" value="Sample Java Methods" />
<option name="STARTUP_CPU_PROFILING_CONFIGURATION_NAME" value="Callstack Sample" />
<option name="STARTUP_NATIVE_MEMORY_PROFILING_ENABLED" value="false" />
<option name="NATIVE_MEMORY_SAMPLE_RATE_BYTES" value="2048" />
</Profilers>
@ -48,4 +50,4 @@
<option name="Android.Gradle.BeforeRunTask" enabled="true" />
</method>
</configuration>
</component>
</component>

View file

@ -0,0 +1,66 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="app" type="AndroidRunConfigurationType" factoryName="Android App" singleton="true">
<module name="seedvault.Seedvault.app.main" />
<option name="DEPLOY" value="true" />
<option name="DEPLOY_APK_FROM_BUNDLE" value="false" />
<option name="DEPLOY_AS_INSTANT" value="false" />
<option name="ARTIFACT_NAME" value="" />
<option name="PM_INSTALL_OPTIONS" value="" />
<option name="ALL_USERS" value="false" />
<option name="ALWAYS_INSTALL_WITH_PM" value="true" />
<option name="CLEAR_APP_STORAGE" value="false" />
<option name="DYNAMIC_FEATURES_DISABLED_LIST" value="" />
<option name="ACTIVITY_EXTRA_FLAGS" value="" />
<option name="MODE" value="default_activity" />
<option name="CLEAR_LOGCAT" value="false" />
<option name="SHOW_LOGCAT_AUTOMATICALLY" value="false" />
<option name="TARGET_SELECTION_MODE" value="DEVICE_AND_SNAPSHOT_COMBO_BOX" />
<option name="DEBUGGER_TYPE" value="Auto" />
<Auto>
<option name="USE_JAVA_AWARE_DEBUGGER" value="false" />
<option name="SHOW_STATIC_VARS" value="true" />
<option name="WORKING_DIR" value="" />
<option name="TARGET_LOGGING_CHANNELS" value="lldb process:gdb-remote packets" />
<option name="SHOW_OPTIMIZED_WARNING" value="true" />
<option name="ATTACH_ON_WAIT_FOR_DEBUGGER" value="false" />
<option name="DEBUG_SANDBOX_SDK" value="false" />
</Auto>
<Hybrid>
<option name="USE_JAVA_AWARE_DEBUGGER" value="false" />
<option name="SHOW_STATIC_VARS" value="true" />
<option name="WORKING_DIR" value="" />
<option name="TARGET_LOGGING_CHANNELS" value="lldb process:gdb-remote packets" />
<option name="SHOW_OPTIMIZED_WARNING" value="true" />
<option name="ATTACH_ON_WAIT_FOR_DEBUGGER" value="false" />
<option name="DEBUG_SANDBOX_SDK" value="false" />
</Hybrid>
<Java>
<option name="ATTACH_ON_WAIT_FOR_DEBUGGER" value="false" />
<option name="DEBUG_SANDBOX_SDK" value="false" />
</Java>
<Native>
<option name="USE_JAVA_AWARE_DEBUGGER" value="false" />
<option name="SHOW_STATIC_VARS" value="true" />
<option name="WORKING_DIR" value="" />
<option name="TARGET_LOGGING_CHANNELS" value="lldb process:gdb-remote packets" />
<option name="SHOW_OPTIMIZED_WARNING" value="true" />
<option name="ATTACH_ON_WAIT_FOR_DEBUGGER" value="false" />
<option name="DEBUG_SANDBOX_SDK" value="false" />
</Native>
<Profilers>
<option name="ADVANCED_PROFILING_ENABLED" value="false" />
<option name="STARTUP_PROFILING_ENABLED" value="false" />
<option name="STARTUP_CPU_PROFILING_ENABLED" value="false" />
<option name="STARTUP_CPU_PROFILING_CONFIGURATION_NAME" value="Java/Kotlin Method Sample (legacy)" />
<option name="STARTUP_NATIVE_MEMORY_PROFILING_ENABLED" value="false" />
<option name="NATIVE_MEMORY_SAMPLE_RATE_BYTES" value="2048" />
</Profilers>
<option name="DEEP_LINK" value="" />
<option name="ACTIVITY_CLASS" value="" />
<option name="SEARCH_ACTIVITY_IN_GLOBAL_SCOPE" value="false" />
<option name="SKIP_ACTIVITY_VALIDATION" value="false" />
<method v="2">
<option name="Android.Gradle.BeforeRunTask" enabled="true" />
</method>
</configuration>
</component>

View file

@ -0,0 +1,68 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="app-emulator" type="AndroidRunConfigurationType" factoryName="Android App">
<module name="Seedvault.app.main" />
<option name="DEPLOY" value="false" />
<option name="DEPLOY_APK_FROM_BUNDLE" value="false" />
<option name="DEPLOY_AS_INSTANT" value="false" />
<option name="ARTIFACT_NAME" value="" />
<option name="PM_INSTALL_OPTIONS" value="" />
<option name="ALL_USERS" value="false" />
<option name="ALWAYS_INSTALL_WITH_PM" value="false" />
<option name="CLEAR_APP_STORAGE" value="false" />
<option name="ACTIVITY_EXTRA_FLAGS" value="" />
<option name="MODE" value="specific_activity" />
<option name="CLEAR_LOGCAT" value="false" />
<option name="SHOW_LOGCAT_AUTOMATICALLY" value="false" />
<option name="INSPECTION_WITHOUT_ACTIVITY_RESTART" value="false" />
<option name="TARGET_SELECTION_MODE" value="SHOW_DIALOG" />
<option name="SELECTED_CLOUD_MATRIX_CONFIGURATION_ID" value="-1" />
<option name="SELECTED_CLOUD_MATRIX_PROJECT_ID" value="" />
<option name="DEBUGGER_TYPE" value="Java" />
<Auto>
<option name="USE_JAVA_AWARE_DEBUGGER" value="false" />
<option name="SHOW_STATIC_VARS" value="true" />
<option name="WORKING_DIR" value="" />
<option name="TARGET_LOGGING_CHANNELS" value="lldb process:gdb-remote packets" />
<option name="SHOW_OPTIMIZED_WARNING" value="true" />
<option name="ATTACH_ON_WAIT_FOR_DEBUGGER" value="true" />
<option name="DEBUG_SANDBOX_SDK" value="false" />
</Auto>
<Hybrid>
<option name="USE_JAVA_AWARE_DEBUGGER" value="false" />
<option name="SHOW_STATIC_VARS" value="true" />
<option name="WORKING_DIR" value="" />
<option name="TARGET_LOGGING_CHANNELS" value="lldb process:gdb-remote packets" />
<option name="SHOW_OPTIMIZED_WARNING" value="true" />
<option name="ATTACH_ON_WAIT_FOR_DEBUGGER" value="false" />
<option name="DEBUG_SANDBOX_SDK" value="false" />
</Hybrid>
<Java>
<option name="ATTACH_ON_WAIT_FOR_DEBUGGER" value="true" />
<option name="DEBUG_SANDBOX_SDK" value="false" />
</Java>
<Native>
<option name="USE_JAVA_AWARE_DEBUGGER" value="false" />
<option name="SHOW_STATIC_VARS" value="true" />
<option name="WORKING_DIR" value="" />
<option name="TARGET_LOGGING_CHANNELS" value="lldb process:gdb-remote packets" />
<option name="SHOW_OPTIMIZED_WARNING" value="true" />
<option name="ATTACH_ON_WAIT_FOR_DEBUGGER" value="false" />
<option name="DEBUG_SANDBOX_SDK" value="false" />
</Native>
<Profilers>
<option name="ADVANCED_PROFILING_ENABLED" value="false" />
<option name="STARTUP_PROFILING_ENABLED" value="false" />
<option name="STARTUP_CPU_PROFILING_ENABLED" value="false" />
<option name="STARTUP_CPU_PROFILING_CONFIGURATION_NAME" value="Java/Kotlin Method Sample (legacy)" />
<option name="STARTUP_NATIVE_MEMORY_PROFILING_ENABLED" value="false" />
<option name="NATIVE_MEMORY_SAMPLE_RATE_BYTES" value="2048" />
</Profilers>
<option name="DEEP_LINK" value="" />
<option name="ACTIVITY_CLASS" value="com.stevesoltys.seedvault.settings.SettingsActivity" />
<option name="SEARCH_ACTIVITY_IN_GLOBAL_SCOPE" value="false" />
<option name="SKIP_ACTIVITY_VALIDATION" value="false" />
<method v="2">
<option name="Gradle.BeforeRunTask" enabled="false" tasks="installEmulatorRelease" externalProjectPath="$PROJECT_DIR$/app" vmOptions="" scriptParameters="" />
</method>
</configuration>
</component>

View file

@ -0,0 +1,3 @@
<component name="DependencyValidationManager">
<scope name="Kotlin Files" pattern="file[Seedvault.app]:*/*.kt" />
</component>

View file

@ -0,0 +1,3 @@
<component name="DependencyValidationManager">
<scope name="XML Files" pattern="file[Seedvault.app]:*/*.xml" />
</component>

72
.reuse/dep5 Normal file
View file

@ -0,0 +1,72 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: Seedvault
Upstream-Contact: The Calyx Institute
Source: https://github.com/seedvault-app/seedvault
Files: .github/workflows/build.yml
.github/workflows/client.yml
.github/workflows/test.yml
.gitignore
CHANGELOG.md README.md app/development/DEVELOPMENT.md
Copyright: 2017-2020 Steve Soltys
2020 The Calyx Institute
License: Apache-2.0
Files: .cirrus.yml .editorconfig .idea/*
app/platform.jks app/development/platform.jks
app/src/main/res/values-*/strings.xml
Copyright: 2020 The Calyx Institute
License: Apache-2.0
Files: libs/dav4jvm/dav4jvm-2.2.1.jar
Copyright: 2024 bitfire web engineering
License: MPL-2.0
Files: libs/dav4jvm/okhttp-4.11.0.jar
libs/dav4jvm/okio-jvm-3.7.0.jar
Copyright: 2024 Square, Inc.
License: Apache-2.0
Files: libs/koin-android/koin-android-3.2.0.aar
libs/koin-android/koin-core-jvm-3.2.0.jar
Copyright: 2022 insert-koin.io
License: Apache-2.0
Files: libs/kotlin-bip39-jvm-1.0.6.jar
Copyright: 2020 Zcash
License: MIT
Files: contactsbackup/*.gitignore contactsbackup/*.md
contactsbackup/src/main/res/values-*/strings.xml
Copyright: 2020 The Calyx Institute
License: Apache-2.0
Files: contactsbackup/libs/com.android.vcard.jar
Copyright: 2010 The Android Open Source Project
License: Apache-2.0
Files: storage/*.gitignore storage/*.md
storage/lib/src/main/proto/*.proto
storage/lib/src/main/res/values-*/strings.xml
Copyright: 2021 The Calyx Institute
License: Apache-2.0
Files: storage/lib/libs/tink-android-1.10.0.jar
Copyright: 2022 Google LLC
License: Apache-2.0
Files: storage/demo/src/main/assets/test.jpg
Copyright: Toytoy at English Wikipedia
License: CC-BY-SA-3.0
Files: storage/demo/src/main/ic_launcher-playstore.png
Copyright: Material Design Authors / Google LLC
License: Apache-2.0
Files: gradle/wrapper/*
Copyright: 2007-2023 Gradle, Inc.
License: Apache-2.0
Files: gradlew*
Copyright: 2007-2023 Gradle, Inc.
License: Apache-2.0

View file

@ -1,17 +1,6 @@
//
// Copyright (C) 2018 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// SPDX-FileCopyrightText: 2020 The Calyx Institute
// SPDX-License-Identifier: Apache-2.0
//
android_app {
@ -19,39 +8,63 @@ android_app {
srcs: [
"app/src/main/java/**/*.kt",
"app/src/main/java/**/*.java",
"app/src/main/proto/*.proto",
// as of Android 15, there is no way to pass --kotlin_out to aprotoc compiler
"app/build/generated/source/proto/debug/kotlin/com/stevesoltys/seedvault/proto/*.kt",
],
resource_dirs: [
"app/src/main/res",
],
asset_dirs: [
"app/src/main/assets"
],
proto: {
type: "lite",
local_include_dirs: ["app/src/main/proto"],
},
static_libs: [
"kotlin-stdlib-jdk8",
"libprotobuf-java-lite",
"androidx.core_core-ktx",
"androidx.fragment_fragment-ktx",
"androidx.activity_activity-ktx",
"androidx.preference_preference",
"androidx.documentfile_documentfile",
"androidx.work_work-runtime-ktx",
"androidx.lifecycle_lifecycle-viewmodel-ktx",
"androidx.lifecycle_lifecycle-livedata-ktx",
"androidx-constraintlayout_constraintlayout",
"com.google.android.material_material",
// storage
"seedvault-lib-storage", // did not manage to add this as transitive dependency
"seedvault-lib-tink-android",
"androidx.room_room-runtime",
"libprotobuf-java-lite",
"kotlinx-coroutines-android",
"kotlinx-coroutines-core",
"seedvault-lib-kotlin-logging-jvm",
// app backup related libs
"seedvault-lib-protobuf-kotlin-lite",
"seedvault-logback-android",
"seedvault-lib-chunker",
"seedvault-lib-zstd-jni",
"okio-lib",
// our own gradle module libs
"seedvault-lib-core",
"seedvault-lib-storage",
// koin
"seedvault-lib-koin-core", // did not manage to add this as transitive dependency
"seedvault-lib-koin-core-jvm", // did not manage to add this as transitive dependency
"seedvault-lib-koin-android",
"seedvault-lib-koin-androidx-viewmodel",
// bip39
"seedvault-lib-kotlin-bip39",
],
use_embedded_native_libs: true,
manifest: "app/src/main/AndroidManifest.xml",
platform_apis: true,
system_ext_specific: true,
certificate: "platform",
privileged: true,
required: [
"LocalContactsBackup",
"privapp_whitelist_com.stevesoltys.backup",
"com.stevesoltys.backup_whitelist"
"com.stevesoltys.backup_allowlist",
"com.stevesoltys.backup_default-permissions",
"com.stevesoltys.backup_privapp_allowlist"
],
optimize: {
enabled: false,
@ -59,15 +72,25 @@ android_app {
}
prebuilt_etc {
name: "privapp_whitelist_com.stevesoltys.backup",
sub_dir: "permissions",
src: "permissions_com.stevesoltys.seedvault.xml",
name: "com.stevesoltys.backup_allowlist",
system_ext_specific: true,
sub_dir: "sysconfig",
src: "allowlist_com.stevesoltys.seedvault.xml",
filename_from_src: true,
}
prebuilt_etc {
name: "com.stevesoltys.backup_whitelist",
sub_dir: "sysconfig",
src: "whitelist_com.stevesoltys.seedvault.xml",
name: "com.stevesoltys.backup_default-permissions",
system_ext_specific: true,
sub_dir: "default-permissions",
src: "default-permissions_com.stevesoltys.seedvault.xml",
filename_from_src: true,
}
prebuilt_etc {
name: "com.stevesoltys.backup_privapp_allowlist",
system_ext_specific: true,
sub_dir: "permissions",
src: "permissions_com.stevesoltys.seedvault.xml",
filename_from_src: true,
}

View file

@ -1,3 +1,76 @@
## [15-5.0] - 2024-10-15
* First Android 15 release
* New backup format using compression and deduplication
* Can still restore old backups, but old Seedvault can't restore backups from this version
* Faster and more reliable backups making snapshots that can individually be restored
* Auto-cleaning of old backups
* All backups now mimic device-to-device (allowing backup for all apps)
* All backups now use a high per-app app quota
* App backup (for APKs) moved to expert settings
* Show more information for backups available to restore
* Fix "Waiting to back up..." showing for apps
## [14-4.1] - 2024-08-23
* It is now possible to restore after setting up a profile
* It is now possible to select what to restore (e.g. apps, files...)
* Automatic backup scheduling can now be modified by the user
* Native support for WebDAV
* Support for RoundSync (if enabled by the OS)
* Now in Material 3
* Name of profile is now shown when selecting a backup to restore
* Already installed apps are not reinstalled anymore
* Already stored files do not create duplicates anymore
* Respect policy when the installation of apps is disallowed
* Storage backup is now beta instead of experimental
* D2D is now alpha instead of experimental
* Various corrections to the UI
## [14-4.0] - 2024-01-24
* Add experimental support for forcing "D2D" transfer backups
* Pretend to be a device-to-device transfer to allow backing up many apps which prevent backup
* Stop backing up excluded app APKs
* Show size of app backups in Backup Status screen
* Slight improvements to color scheme
* Development: Improve CI testing setup
## [14-3.3] - 2023-10-06
* Android 14
## [13-3.3] - 2023-01-11
* Mark Nextcloud as "Not recommended"
* Warn before turning off backups
* Avoid corrupting old backups when turning off backups
* Pre-grant `ACCESS_MEDIA_LOCATION` permission for Storage backups
## [13-3.2] - 2022-12-29
* Add expert option to save logs
* Add more details about branching to README
* Improvements for debug builds
* Documentation improvements
* Better error handling in some cases
* Some Android 13 upgrades
## [13-3.1] - 2022-09-01
* Initial release for Android 13
* Don't attempt to restore app that is used as a backup location (e.g. Nextcloud),
because can cause restore to abort early
* Upgrade several libraries
## [12-3.0] - 2021-10-13
* Initial release for Android 12
* Use the same (faster and more secure) crypto that storage backups use,
for app backup.
* Avoid leaking installed app list through filenames by using salted names
* Old backups can still be restored, but new backups will be made with this format
* If you generated the recovery code / setup Seedvault before 11-1.2, you will be prompted
to generate a new code.
* Improve backup behavior in general
## [11-2.3] - 2021-10-02
### Fixed
* Fix translations for the new BIP39 library
* Switch all translations references to github.com/seedvault-app
## [11-2.2] - 2021-09-29
### User-facing changes
* Don't backup on metered networks

202
LICENSE
View file

@ -1,202 +0,0 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [2019] [Steve Soltys]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View file

@ -0,0 +1,235 @@
GNU AFFERO GENERAL PUBLIC LICENSE
Version 3, 19 November 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
Preamble
The GNU Affero General Public License is a free, copyleft license for software and other kinds of works, specifically designed to ensure cooperation with the community in the case of network server software.
The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, our General Public Licenses are intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users.
When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things.
Developers that use our General Public Licenses protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License which gives you legal permission to copy, distribute and/or modify the software.
A secondary benefit of defending all users' freedom is that improvements made in alternate versions of the program, if they receive widespread use, become available for other developers to incorporate. Many developers of free software are heartened and encouraged by the resulting cooperation. However, in the case of software used on network servers, this result may fail to come about. The GNU General Public License permits making a modified version and letting the public access it on a server without ever releasing its source code to the public.
The GNU Affero General Public License is designed specifically to ensure that, in such cases, the modified source code becomes available to the community. It requires the operator of a network server to provide the source code of the modified version running there to the users of that server. Therefore, public use of a modified version, on a publicly accessible server, gives the public access to the source code of the modified version.
An older license, called the Affero General Public License and published by Affero, was designed to accomplish similar goals. This is a different license, not a version of the Affero GPL, but Affero has released a new version of the Affero GPL which permits relicensing under this license.
The precise terms and conditions for copying, distribution and modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU Affero General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based on the Program.
To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work.
A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source.
The Corresponding Source for a work in source code form is that same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures.
When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified it, and giving a relevant date.
b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices".
c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so.
A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways:
a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b.
d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d.
A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product.
"Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made.
If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM).
The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or authors of the material; or
e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors.
All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11).
However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice.
Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party.
If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it.
A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program.
13. Remote Network Interaction; Use with the GNU General Public License.
Notwithstanding any other provision of this License, if you modify the Program, your modified version must prominently offer all users interacting with it remotely through a computer network (if your version supports such interaction) an opportunity to receive the Corresponding Source of your version by providing access to the Corresponding Source from a network server at no charge, through some standard or customary means of facilitating copying of software. This Corresponding Source shall include the Corresponding Source for any work covered by version 3 of the GNU General Public License that is incorporated pursuant to the following paragraph.
Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the work with which it is combined will remain governed by version 3 of the GNU General Public License.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of the GNU Affero General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU Affero General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU Affero General Public License, you may choose any version ever published by the Free Software Foundation.
If the Program specifies that a proxy can decide which future versions of the GNU Affero General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program.
Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If your software can interact with users remotely through a computer network, you should also make sure that it provides a way for users to get its source. For example, if your program is a web application, its interface could display a "Source" link that leads users to an archive of the code. There are many ways you could offer source, and different solutions will be better for different programs; see section 13 for the specific requirements.
You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU AGPL, see <http://www.gnu.org/licenses/>.

73
LICENSES/Apache-2.0.txt Normal file
View file

@ -0,0 +1,73 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
(a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

99
LICENSES/CC-BY-SA-3.0.txt Normal file
View file

@ -0,0 +1,99 @@
Creative Commons Attribution-ShareAlike 3.0 Unported
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE LEGAL SERVICES. DISTRIBUTION OF THIS LICENSE DOES NOT CREATE AN ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES REGARDING THE INFORMATION PROVIDED, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM ITS USE.
License
THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE MAY BE CONSIDERED TO BE A CONTRACT, THE LICENSOR GRANTS YOU THE RIGHTS CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND CONDITIONS.
1. Definitions
a. "Adaptation" means a work based upon the Work, or upon the Work and other pre-existing works, such as a translation, adaptation, derivative work, arrangement of music or other alterations of a literary or artistic work, or phonogram or performance and includes cinematographic adaptations or any other form in which the Work may be recast, transformed, or adapted including in any form recognizably derived from the original, except that a work that constitutes a Collection will not be considered an Adaptation for the purpose of this License. For the avoidance of doubt, where the Work is a musical work, performance or phonogram, the synchronization of the Work in timed-relation with a moving image ("synching") will be considered an Adaptation for the purpose of this License.
b. "Collection" means a collection of literary or artistic works, such as encyclopedias and anthologies, or performances, phonograms or broadcasts, or other works or subject matter other than works listed in Section 1(f) below, which, by reason of the selection and arrangement of their contents, constitute intellectual creations, in which the Work is included in its entirety in unmodified form along with one or more other contributions, each constituting separate and independent works in themselves, which together are assembled into a collective whole. A work that constitutes a Collection will not be considered an Adaptation (as defined below) for the purposes of this License.
c. "Creative Commons Compatible License" means a license that is listed at http://creativecommons.org/compatiblelicenses that has been approved by Creative Commons as being essentially equivalent to this License, including, at a minimum, because that license: (i) contains terms that have the same purpose, meaning and effect as the License Elements of this License; and, (ii) explicitly permits the relicensing of adaptations of works made available under that license under this License or a Creative Commons jurisdiction license with the same License Elements as this License.
d. "Distribute" means to make available to the public the original and copies of the Work or Adaptation, as appropriate, through sale or other transfer of ownership.
e. "License Elements" means the following high-level license attributes as selected by Licensor and indicated in the title of this License: Attribution, ShareAlike.
f. "Licensor" means the individual, individuals, entity or entities that offer(s) the Work under the terms of this License.
g. "Original Author" means, in the case of a literary or artistic work, the individual, individuals, entity or entities who created the Work or if no individual or entity can be identified, the publisher; and in addition (i) in the case of a performance the actors, singers, musicians, dancers, and other persons who act, sing, deliver, declaim, play in, interpret or otherwise perform literary or artistic works or expressions of folklore; (ii) in the case of a phonogram the producer being the person or legal entity who first fixes the sounds of a performance or other sounds; and, (iii) in the case of broadcasts, the organization that transmits the broadcast.
h. "Work" means the literary and/or artistic work offered under the terms of this License including without limitation any production in the literary, scientific and artistic domain, whatever may be the mode or form of its expression including digital form, such as a book, pamphlet and other writing; a lecture, address, sermon or other work of the same nature; a dramatic or dramatico-musical work; a choreographic work or entertainment in dumb show; a musical composition with or without words; a cinematographic work to which are assimilated works expressed by a process analogous to cinematography; a work of drawing, painting, architecture, sculpture, engraving or lithography; a photographic work to which are assimilated works expressed by a process analogous to photography; a work of applied art; an illustration, map, plan, sketch or three-dimensional work relative to geography, topography, architecture or science; a performance; a broadcast; a phonogram; a compilation of data to the extent it is protected as a copyrightable work; or a work performed by a variety or circus performer to the extent it is not otherwise considered a literary or artistic work.
i. "You" means an individual or entity exercising rights under this License who has not previously violated the terms of this License with respect to the Work, or who has received express permission from the Licensor to exercise rights under this License despite a previous violation.
j. "Publicly Perform" means to perform public recitations of the Work and to communicate to the public those public recitations, by any means or process, including by wire or wireless means or public digital performances; to make available to the public Works in such a way that members of the public may access these Works from a place and at a place individually chosen by them; to perform the Work to the public by any means or process and the communication to the public of the performances of the Work, including by public digital performance; to broadcast and rebroadcast the Work by any means including signs, sounds or images.
k. "Reproduce" means to make copies of the Work by any means including without limitation by sound or visual recordings and the right of fixation and reproducing fixations of the Work, including storage of a protected performance or phonogram in digital form or other electronic medium.
2. Fair Dealing Rights. Nothing in this License is intended to reduce, limit, or restrict any uses free from copyright or rights arising from limitations or exceptions that are provided for in connection with the copyright protection under copyright law or other applicable laws.
3. License Grant. Subject to the terms and conditions of this License, Licensor hereby grants You a worldwide, royalty-free, non-exclusive, perpetual (for the duration of the applicable copyright) license to exercise the rights in the Work as stated below:
a. to Reproduce the Work, to incorporate the Work into one or more Collections, and to Reproduce the Work as incorporated in the Collections;
b. to create and Reproduce Adaptations provided that any such Adaptation, including any translation in any medium, takes reasonable steps to clearly label, demarcate or otherwise identify that changes were made to the original Work. For example, a translation could be marked "The original work was translated from English to Spanish," or a modification could indicate "The original work has been modified.";
c. to Distribute and Publicly Perform the Work including as incorporated in Collections; and,
d. to Distribute and Publicly Perform Adaptations.
e. For the avoidance of doubt:
i. Non-waivable Compulsory License Schemes. In those jurisdictions in which the right to collect royalties through any statutory or compulsory licensing scheme cannot be waived, the Licensor reserves the exclusive right to collect such royalties for any exercise by You of the rights granted under this License;
ii. Waivable Compulsory License Schemes. In those jurisdictions in which the right to collect royalties through any statutory or compulsory licensing scheme can be waived, the Licensor waives the exclusive right to collect such royalties for any exercise by You of the rights granted under this License; and,
iii. Voluntary License Schemes. The Licensor waives the right to collect royalties, whether individually or, in the event that the Licensor is a member of a collecting society that administers voluntary licensing schemes, via that society, from any exercise by You of the rights granted under this License.
The above rights may be exercised in all media and formats whether now known or hereafter devised. The above rights include the right to make such modifications as are technically necessary to exercise the rights in other media and formats. Subject to Section 8(f), all rights not expressly granted by Licensor are hereby reserved.
4. Restrictions. The license granted in Section 3 above is expressly made subject to and limited by the following restrictions:
a. You may Distribute or Publicly Perform the Work only under the terms of this License. You must include a copy of, or the Uniform Resource Identifier (URI) for, this License with every copy of the Work You Distribute or Publicly Perform. You may not offer or impose any terms on the Work that restrict the terms of this License or the ability of the recipient of the Work to exercise the rights granted to that recipient under the terms of the License. You may not sublicense the Work. You must keep intact all notices that refer to this License and to the disclaimer of warranties with every copy of the Work You Distribute or Publicly Perform. When You Distribute or Publicly Perform the Work, You may not impose any effective technological measures on the Work that restrict the ability of a recipient of the Work from You to exercise the rights granted to that recipient under the terms of the License. This Section 4(a) applies to the Work as incorporated in a Collection, but this does not require the Collection apart from the Work itself to be made subject to the terms of this License. If You create a Collection, upon notice from any Licensor You must, to the extent practicable, remove from the Collection any credit as required by Section 4(c), as requested. If You create an Adaptation, upon notice from any Licensor You must, to the extent practicable, remove from the Adaptation any credit as required by Section 4(c), as requested.
b. You may Distribute or Publicly Perform an Adaptation only under the terms of: (i) this License; (ii) a later version of this License with the same License Elements as this License; (iii) a Creative Commons jurisdiction license (either this or a later license version) that contains the same License Elements as this License (e.g., Attribution-ShareAlike 3.0 US)); (iv) a Creative Commons Compatible License. If you license the Adaptation under one of the licenses mentioned in (iv), you must comply with the terms of that license. If you license the Adaptation under the terms of any of the licenses mentioned in (i), (ii) or (iii) (the "Applicable License"), you must comply with the terms of the Applicable License generally and the following provisions: (I) You must include a copy of, or the URI for, the Applicable License with every copy of each Adaptation You Distribute or Publicly Perform; (II) You may not offer or impose any terms on the Adaptation that restrict the terms of the Applicable License or the ability of the recipient of the Adaptation to exercise the rights granted to that recipient under the terms of the Applicable License; (III) You must keep intact all notices that refer to the Applicable License and to the disclaimer of warranties with every copy of the Work as included in the Adaptation You Distribute or Publicly Perform; (IV) when You Distribute or Publicly Perform the Adaptation, You may not impose any effective technological measures on the Adaptation that restrict the ability of a recipient of the Adaptation from You to exercise the rights granted to that recipient under the terms of the Applicable License. This Section 4(b) applies to the Adaptation as incorporated in a Collection, but this does not require the Collection apart from the Adaptation itself to be made subject to the terms of the Applicable License.
c. If You Distribute, or Publicly Perform the Work or any Adaptations or Collections, You must, unless a request has been made pursuant to Section 4(a), keep intact all copyright notices for the Work and provide, reasonable to the medium or means You are utilizing: (i) the name of the Original Author (or pseudonym, if applicable) if supplied, and/or if the Original Author and/or Licensor designate another party or parties (e.g., a sponsor institute, publishing entity, journal) for attribution ("Attribution Parties") in Licensor's copyright notice, terms of service or by other reasonable means, the name of such party or parties; (ii) the title of the Work if supplied; (iii) to the extent reasonably practicable, the URI, if any, that Licensor specifies to be associated with the Work, unless such URI does not refer to the copyright notice or licensing information for the Work; and (iv) , consistent with Ssection 3(b), in the case of an Adaptation, a credit identifying the use of the Work in the Adaptation (e.g., "French translation of the Work by Original Author," or "Screenplay based on original Work by Original Author"). The credit required by this Section 4(c) may be implemented in any reasonable manner; provided, however, that in the case of a Adaptation or Collection, at a minimum such credit will appear, if a credit for all contributing authors of the Adaptation or Collection appears, then as part of these credits and in a manner at least as prominent as the credits for the other contributing authors. For the avoidance of doubt, You may only use the credit required by this Section for the purpose of attribution in the manner set out above and, by exercising Your rights under this License, You may not implicitly or explicitly assert or imply any connection with, sponsorship or endorsement by the Original Author, Licensor and/or Attribution Parties, as appropriate, of You or Your use of the Work, without the separate, express prior written permission of the Original Author, Licensor and/or Attribution Parties.
d. Except as otherwise agreed in writing by the Licensor or as may be otherwise permitted by applicable law, if You Reproduce, Distribute or Publicly Perform the Work either by itself or as part of any Adaptations or Collections, You must not distort, mutilate, modify or take other derogatory action in relation to the Work which would be prejudicial to the Original Author's honor or reputation. Licensor agrees that in those jurisdictions (e.g. Japan), in which any exercise of the right granted in Section 3(b) of this License (the right to make Adaptations) would be deemed to be a distortion, mutilation, modification or other derogatory action prejudicial to the Original Author's honor and reputation, the Licensor will waive or not assert, as appropriate, this Section, to the fullest extent permitted by the applicable national law, to enable You to reasonably exercise Your right under Section 3(b) of this License (right to make Adaptations) but not otherwise.
5. Representations, Warranties and Disclaimer
UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN WRITING, LICENSOR OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE WORK, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE, INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTIBILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS, WHETHER OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU.
6. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
7. Termination
a. This License and the rights granted hereunder will terminate automatically upon any breach by You of the terms of this License. Individuals or entities who have received Adaptations or Collections from You under this License, however, will not have their licenses terminated provided such individuals or entities remain in full compliance with those licenses. Sections 1, 2, 5, 6, 7, and 8 will survive any termination of this License.
b. Subject to the above terms and conditions, the license granted here is perpetual (for the duration of the applicable copyright in the Work). Notwithstanding the above, Licensor reserves the right to release the Work under different license terms or to stop distributing the Work at any time; provided, however that any such election will not serve to withdraw this License (or any other license that has been, or is required to be, granted under the terms of this License), and this License will continue in full force and effect unless terminated as stated above.
8. Miscellaneous
a. Each time You Distribute or Publicly Perform the Work or a Collection, the Licensor offers to the recipient a license to the Work on the same terms and conditions as the license granted to You under this License.
b. Each time You Distribute or Publicly Perform an Adaptation, Licensor offers to the recipient a license to the original Work on the same terms and conditions as the license granted to You under this License.
c. If any provision of this License is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this License, and without further action by the parties to this agreement, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
d. No term or provision of this License shall be deemed waived and no breach consented to unless such waiver or consent shall be in writing and signed by the party to be charged with such waiver or consent.
e. This License constitutes the entire agreement between the parties with respect to the Work licensed here. There are no understandings, agreements or representations with respect to the Work not specified here. Licensor shall not be bound by any additional provisions that may appear in any communication from You. This License may not be modified without the mutual written agreement of the Licensor and You.
f. The rights granted under, and the subject matter referenced, in this License were drafted utilizing the terminology of the Berne Convention for the Protection of Literary and Artistic Works (as amended on September 28, 1979), the Rome Convention of 1961, the WIPO Copyright Treaty of 1996, the WIPO Performances and Phonograms Treaty of 1996 and the Universal Copyright Convention (as revised on July 24, 1971). These rights and subject matter take effect in the relevant jurisdiction in which the License terms are sought to be enforced according to the corresponding provisions of the implementation of those treaty provisions in the applicable national law. If the standard suite of rights granted under applicable copyright law includes additional rights not granted under this License, such additional rights are deemed to be included in the License; this License is not intended to restrict the license of any rights under applicable law.
Creative Commons Notice
Creative Commons is not a party to this License, and makes no warranty whatsoever in connection with the Work. Creative Commons will not be liable to You or any party on any legal theory for any damages whatsoever, including without limitation any general, special, incidental or consequential damages arising in connection to this license. Notwithstanding the foregoing two (2) sentences, if Creative Commons has expressly identified itself as the Licensor hereunder, it shall have all rights and obligations of Licensor.
Except for the limited purpose of indicating to the public that the Work is licensed under the CCPL, Creative Commons does not authorize the use by either party of the trademark "Creative Commons" or any related trademark or logo of Creative Commons without the prior written consent of Creative Commons. Any permitted use will be in compliance with Creative Commons' then-current trademark usage guidelines, as may be published on its website or otherwise made available upon request from time to time. For the avoidance of doubt, this trademark restriction does not form part of the License.
Creative Commons may be contacted at http://creativecommons.org/.

232
LICENSES/GPL-3.0-only.txt Normal file
View file

@ -0,0 +1,232 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright © 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for software and other kinds of works.
The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too.
When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.
Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions.
Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and modification follow.
TERMS AND CONDITIONS
0. Definitions.
“This License” refers to version 3 of the GNU General Public License.
“Copyright” also means copyright-like laws that apply to other kinds of works, such as semiconductor masks.
“The Program” refers to any copyrightable work licensed under this License. Each licensee is addressed as “you”. “Licensees” and “recipients” may be individuals or organizations.
To “modify” a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a “modified version” of the earlier work or a work “based on” the earlier work.
A “covered work” means either the unmodified Program or a work based on the Program.
To “propagate” a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well.
To “convey” a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays “Appropriate Legal Notices” to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion.
1. Source Code.
The “source code” for a work means the preferred form of the work for making modifications to it. “Object code” means any non-source form of a work.
A “Standard Interface” means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language.
The “System Libraries” of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A “Major Component”, in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it.
The “Corresponding Source” for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work.
The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source.
The Corresponding Source for a work in source code form is that same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures.
When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified it, and giving a relevant date.
b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to “keep intact all notices”.
c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so.
A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an “aggregate” if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways:
a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b.
d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d.
A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work.
A “User Product” is either (1) a “consumer product”, which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, “normally used” refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product.
“Installation Information” for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made.
If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM).
The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying.
7. Additional Terms.
“Additional permissions” are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or authors of the material; or
e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors.
All other non-permissive additional terms are considered “further restrictions” within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11).
However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice.
Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License.
An “entity transaction” is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it.
11. Patents.
A “contributor” is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's “contributor version”.
A contributor's “essential patent claims” are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, “control” includes the right to grant patent sublicenses in a manner consistent with the requirements of this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version.
In the following three paragraphs, a “patent license” is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To “grant” such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party.
If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. “Knowingly relying” means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it.
A patent license is “discriminatory” if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License “or any later version” applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation.
If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program.
Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the “copyright” line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an “about box”.
You should also get your employer (if you work as a programmer) or school, if any, to sign a “copyright disclaimer” for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see <http://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read <http://www.gnu.org/philosophy/why-not-lgpl.html>.

9
LICENSES/MIT.txt Normal file
View file

@ -0,0 +1,9 @@
MIT License
Copyright (c) <year> <copyright holders>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

373
LICENSES/MPL-2.0.txt Normal file
View file

@ -0,0 +1,373 @@
Mozilla Public License Version 2.0
==================================
1. Definitions
--------------
1.1. "Contributor"
means each individual or legal entity that creates, contributes to
the creation of, or owns Covered Software.
1.2. "Contributor Version"
means the combination of the Contributions of others (if any) used
by a Contributor and that particular Contributor's Contribution.
1.3. "Contribution"
means Covered Software of a particular Contributor.
1.4. "Covered Software"
means Source Code Form to which the initial Contributor has attached
the notice in Exhibit A, the Executable Form of such Source Code
Form, and Modifications of such Source Code Form, in each case
including portions thereof.
1.5. "Incompatible With Secondary Licenses"
means
(a) that the initial Contributor has attached the notice described
in Exhibit B to the Covered Software; or
(b) that the Covered Software was made available under the terms of
version 1.1 or earlier of the License, but not also under the
terms of a Secondary License.
1.6. "Executable Form"
means any form of the work other than Source Code Form.
1.7. "Larger Work"
means a work that combines Covered Software with other material, in
a separate file or files, that is not Covered Software.
1.8. "License"
means this document.
1.9. "Licensable"
means having the right to grant, to the maximum extent possible,
whether at the time of the initial grant or subsequently, any and
all of the rights conveyed by this License.
1.10. "Modifications"
means any of the following:
(a) any file in Source Code Form that results from an addition to,
deletion from, or modification of the contents of Covered
Software; or
(b) any new file in Source Code Form that contains any Covered
Software.
1.11. "Patent Claims" of a Contributor
means any patent claim(s), including without limitation, method,
process, and apparatus claims, in any patent Licensable by such
Contributor that would be infringed, but for the grant of the
License, by the making, using, selling, offering for sale, having
made, import, or transfer of either its Contributions or its
Contributor Version.
1.12. "Secondary License"
means either the GNU General Public License, Version 2.0, the GNU
Lesser General Public License, Version 2.1, the GNU Affero General
Public License, Version 3.0, or any later versions of those
licenses.
1.13. "Source Code Form"
means the form of the work preferred for making modifications.
1.14. "You" (or "Your")
means an individual or a legal entity exercising rights under this
License. For legal entities, "You" includes any entity that
controls, is controlled by, or is under common control with You. For
purposes of this definition, "control" means (a) the power, direct
or indirect, to cause the direction or management of such entity,
whether by contract or otherwise, or (b) ownership of more than
fifty percent (50%) of the outstanding shares or beneficial
ownership of such entity.
2. License Grants and Conditions
--------------------------------
2.1. Grants
Each Contributor hereby grants You a world-wide, royalty-free,
non-exclusive license:
(a) under intellectual property rights (other than patent or trademark)
Licensable by such Contributor to use, reproduce, make available,
modify, display, perform, distribute, and otherwise exploit its
Contributions, either on an unmodified basis, with Modifications, or
as part of a Larger Work; and
(b) under Patent Claims of such Contributor to make, use, sell, offer
for sale, have made, import, and otherwise transfer either its
Contributions or its Contributor Version.
2.2. Effective Date
The licenses granted in Section 2.1 with respect to any Contribution
become effective for each Contribution on the date the Contributor first
distributes such Contribution.
2.3. Limitations on Grant Scope
The licenses granted in this Section 2 are the only rights granted under
this License. No additional rights or licenses will be implied from the
distribution or licensing of Covered Software under this License.
Notwithstanding Section 2.1(b) above, no patent license is granted by a
Contributor:
(a) for any code that a Contributor has removed from Covered Software;
or
(b) for infringements caused by: (i) Your and any other third party's
modifications of Covered Software, or (ii) the combination of its
Contributions with other software (except as part of its Contributor
Version); or
(c) under Patent Claims infringed by Covered Software in the absence of
its Contributions.
This License does not grant any rights in the trademarks, service marks,
or logos of any Contributor (except as may be necessary to comply with
the notice requirements in Section 3.4).
2.4. Subsequent Licenses
No Contributor makes additional grants as a result of Your choice to
distribute the Covered Software under a subsequent version of this
License (see Section 10.2) or under the terms of a Secondary License (if
permitted under the terms of Section 3.3).
2.5. Representation
Each Contributor represents that the Contributor believes its
Contributions are its original creation(s) or it has sufficient rights
to grant the rights to its Contributions conveyed by this License.
2.6. Fair Use
This License is not intended to limit any rights You have under
applicable copyright doctrines of fair use, fair dealing, or other
equivalents.
2.7. Conditions
Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
in Section 2.1.
3. Responsibilities
-------------------
3.1. Distribution of Source Form
All distribution of Covered Software in Source Code Form, including any
Modifications that You create or to which You contribute, must be under
the terms of this License. You must inform recipients that the Source
Code Form of the Covered Software is governed by the terms of this
License, and how they can obtain a copy of this License. You may not
attempt to alter or restrict the recipients' rights in the Source Code
Form.
3.2. Distribution of Executable Form
If You distribute Covered Software in Executable Form then:
(a) such Covered Software must also be made available in Source Code
Form, as described in Section 3.1, and You must inform recipients of
the Executable Form how they can obtain a copy of such Source Code
Form by reasonable means in a timely manner, at a charge no more
than the cost of distribution to the recipient; and
(b) You may distribute such Executable Form under the terms of this
License, or sublicense it under different terms, provided that the
license for the Executable Form does not attempt to limit or alter
the recipients' rights in the Source Code Form under this License.
3.3. Distribution of a Larger Work
You may create and distribute a Larger Work under terms of Your choice,
provided that You also comply with the requirements of this License for
the Covered Software. If the Larger Work is a combination of Covered
Software with a work governed by one or more Secondary Licenses, and the
Covered Software is not Incompatible With Secondary Licenses, this
License permits You to additionally distribute such Covered Software
under the terms of such Secondary License(s), so that the recipient of
the Larger Work may, at their option, further distribute the Covered
Software under the terms of either this License or such Secondary
License(s).
3.4. Notices
You may not remove or alter the substance of any license notices
(including copyright notices, patent notices, disclaimers of warranty,
or limitations of liability) contained within the Source Code Form of
the Covered Software, except that You may alter any license notices to
the extent required to remedy known factual inaccuracies.
3.5. Application of Additional Terms
You may choose to offer, and to charge a fee for, warranty, support,
indemnity or liability obligations to one or more recipients of Covered
Software. However, You may do so only on Your own behalf, and not on
behalf of any Contributor. You must make it absolutely clear that any
such warranty, support, indemnity, or liability obligation is offered by
You alone, and You hereby agree to indemnify every Contributor for any
liability incurred by such Contributor as a result of warranty, support,
indemnity or liability terms You offer. You may include additional
disclaimers of warranty and limitations of liability specific to any
jurisdiction.
4. Inability to Comply Due to Statute or Regulation
---------------------------------------------------
If it is impossible for You to comply with any of the terms of this
License with respect to some or all of the Covered Software due to
statute, judicial order, or regulation then You must: (a) comply with
the terms of this License to the maximum extent possible; and (b)
describe the limitations and the code they affect. Such description must
be placed in a text file included with all distributions of the Covered
Software under this License. Except to the extent prohibited by statute
or regulation, such description must be sufficiently detailed for a
recipient of ordinary skill to be able to understand it.
5. Termination
--------------
5.1. The rights granted under this License will terminate automatically
if You fail to comply with any of its terms. However, if You become
compliant, then the rights granted under this License from a particular
Contributor are reinstated (a) provisionally, unless and until such
Contributor explicitly and finally terminates Your grants, and (b) on an
ongoing basis, if such Contributor fails to notify You of the
non-compliance by some reasonable means prior to 60 days after You have
come back into compliance. Moreover, Your grants from a particular
Contributor are reinstated on an ongoing basis if such Contributor
notifies You of the non-compliance by some reasonable means, this is the
first time You have received notice of non-compliance with this License
from such Contributor, and You become compliant prior to 30 days after
Your receipt of the notice.
5.2. If You initiate litigation against any entity by asserting a patent
infringement claim (excluding declaratory judgment actions,
counter-claims, and cross-claims) alleging that a Contributor Version
directly or indirectly infringes any patent, then the rights granted to
You by any and all Contributors for the Covered Software under Section
2.1 of this License shall terminate.
5.3. In the event of termination under Sections 5.1 or 5.2 above, all
end user license agreements (excluding distributors and resellers) which
have been validly granted by You or Your distributors under this License
prior to termination shall survive termination.
************************************************************************
* *
* 6. Disclaimer of Warranty *
* ------------------------- *
* *
* Covered Software is provided under this License on an "as is" *
* basis, without warranty of any kind, either expressed, implied, or *
* statutory, including, without limitation, warranties that the *
* Covered Software is free of defects, merchantable, fit for a *
* particular purpose or non-infringing. The entire risk as to the *
* quality and performance of the Covered Software is with You. *
* Should any Covered Software prove defective in any respect, You *
* (not any Contributor) assume the cost of any necessary servicing, *
* repair, or correction. This disclaimer of warranty constitutes an *
* essential part of this License. No use of any Covered Software is *
* authorized under this License except under this disclaimer. *
* *
************************************************************************
************************************************************************
* *
* 7. Limitation of Liability *
* -------------------------- *
* *
* Under no circumstances and under no legal theory, whether tort *
* (including negligence), contract, or otherwise, shall any *
* Contributor, or anyone who distributes Covered Software as *
* permitted above, be liable to You for any direct, indirect, *
* special, incidental, or consequential damages of any character *
* including, without limitation, damages for lost profits, loss of *
* goodwill, work stoppage, computer failure or malfunction, or any *
* and all other commercial damages or losses, even if such party *
* shall have been informed of the possibility of such damages. This *
* limitation of liability shall not apply to liability for death or *
* personal injury resulting from such party's negligence to the *
* extent applicable law prohibits such limitation. Some *
* jurisdictions do not allow the exclusion or limitation of *
* incidental or consequential damages, so this exclusion and *
* limitation may not apply to You. *
* *
************************************************************************
8. Litigation
-------------
Any litigation relating to this License may be brought only in the
courts of a jurisdiction where the defendant maintains its principal
place of business and such litigation shall be governed by laws of that
jurisdiction, without reference to its conflict-of-law provisions.
Nothing in this Section shall prevent a party's ability to bring
cross-claims or counter-claims.
9. Miscellaneous
----------------
This License represents the complete agreement concerning the subject
matter hereof. If any provision of this License is held to be
unenforceable, such provision shall be reformed only to the extent
necessary to make it enforceable. Any law or regulation which provides
that the language of a contract shall be construed against the drafter
shall not be used to construe this License against a Contributor.
10. Versions of the License
---------------------------
10.1. New Versions
Mozilla Foundation is the license steward. Except as provided in Section
10.3, no one other than the license steward has the right to modify or
publish new versions of this License. Each version will be given a
distinguishing version number.
10.2. Effect of New Versions
You may distribute the Covered Software under the terms of the version
of the License under which You originally received the Covered Software,
or under the terms of any subsequent version published by the license
steward.
10.3. Modified Versions
If you create software not governed by this License, and you want to
create a new license for such software, you may create and use a
modified version of this License if you rename the license and remove
any references to the name of the license steward (except to note that
such modified license differs from this License).
10.4. Distributing Source Code Form that is Incompatible With Secondary
Licenses
If You choose to distribute Source Code Form that is Incompatible With
Secondary Licenses under the terms of this version of the License, the
notice described in Exhibit B of this License must be attached.
Exhibit A - Source Code Form License Notice
-------------------------------------------
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at https://mozilla.org/MPL/2.0/.
If it is not possible or desirable to put the notice in a particular
file, then You may include the notice in a location (such as a LICENSE
file in a relevant directory) where a recipient would be likely to look
for such a notice.
You may add additional accurate notices of copyright ownership.
Exhibit B - "Incompatible With Secondary Licenses" Notice
---------------------------------------------------------
This Source Code Form is "Incompatible With Secondary Licenses", as
defined by the Mozilla Public License, v. 2.0.

View file

@ -1,15 +1,21 @@
# Seedvault
[![Build](https://github.com/seedvault-app/seedvault/workflows/Build/badge.svg?branch=master)](https://github.com/seedvault-app/seedvault/actions?query=branch%3Amaster+workflow%3ABuild)
[![Build](https://github.com/seedvault-app/seedvault/actions/workflows/build.yml/badge.svg)](https://github.com/seedvault-app/seedvault/actions/workflows/build.yml)
A backup application for the [Android Open Source Project](https://source.android.com/).
Needs to be [integrated](https://github.com/seedvault-app/seedvault/wiki/ROM-Integration)
in your Android ROM and **can not** be installed as a regular app.
If you are having an issue/question, please look at our [FAQ](../../wiki/FAQ).
If you are having an issue/question,
please look at our [FAQ](https://github.com/seedvault-app/seedvault/wiki/FAQ)
or [ask a new question](https://github.com/seedvault-app/seedvault/discussions).
## Components
* [Local Contacts Backup](contactsbackup) - an app that backs up local on-device contacts
* [Storage library](storage) - a library handling efficient backup of files
* [File backup library](storage) - a library handling efficient backup of files
([documentation](storage/doc/design.md))
* [Seedvault app](app) - the main app where all functionality comes together
([documentation](doc/README.md))
## Features
- Backup application data to a flash drive.
@ -19,15 +25,27 @@ If you are having an issue/question, please look at our [FAQ](../../wiki/FAQ).
## Requirements
- Android 11
SeedVault is developed along with AOSP releases.
For older versions of Android, check out [the branches](https://github.com/seedvault-app/seedvault/branches).
We update it every time Google releases a new Android version,
make any changes required for basic functionality,
and any improvements possible through API changes in the OS.
## Getting Started
- Check out [the wiki](https://github.com/seedvault-app/seedvault/wiki) for information on building the application with
AOSP.
This means that for ROMs using SeedVault it's recommended
to use the same branch as your android version
- This current branch `android15` is meant for usage with Android 15
- This is indicated by the version name starting with `15`,
and the version code starting with `35` - the Android 15 API version
For older versions of Android,
check out [the branches](https://github.com/seedvault-app/seedvault/branches).
Trying to use an older branch on a newer version may lead to issues
and is not something we can support.
## What makes this different?
This application is compiled with the operating system and does not require a rooted device for use.
It uses the same internal APIs as `adb backup` which is deprecated and thus needs a replacement.
@ -37,17 +55,25 @@ It uses the same internal APIs as `adb backup` which is deprecated and thus need
* `android.permission.MANAGE_USB` to access the serial number of USB mass storage devices.
* `android.permission.WRITE_SECURE_SETTINGS` to change system backup settings and enable call log backup.
* `android.permission.QUERY_ALL_PACKAGES` to get information about all installed apps for backup.
* `android.permission.QUERY_USERS` to get the name of the user profile that gets backed up.
* `android.permission.INSTALL_PACKAGES` to re-install apps when restoring from backup.
* `android.permission.MANAGE_EXTERNAL_STORAGE` to backup and restore files from device storage.
* `android.permission.ACCESS_MEDIA_LOCATION` to backup original media files e.g. without stripped EXIF metadata.
* `android.permission.FOREGROUND_SERVICE` to do periodic storage backups without interruption.
* `android.permission.FOREGROUND_SERVICE_DATA_SYNC` to do periodic storage backups without interruption.
* `android.permission.MANAGE_DOCUMENTS` to retrieve the available storage roots (optional) for better UX.
* `android.permission.USE_BIOMETRIC` to authenticate saving a new recovery code
* `android.permission.INTERACT_ACROSS_USERS_FULL` to use storage roots in other users (optional).
* `android.permission.POST_NOTIFICATIONS` to inform users about backup status and errors.
## Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/seedvault-app/seedvault.
This project aims to adhere to the [official Kotlin coding style](https://developer.android.com/kotlin/style-guide).
See [DEVELOPMENT.md](app/development/DEVELOPMENT.md) for information
on developing Seedvault locally.
This project aims to adhere to the
[official Kotlin coding style](https://developer.android.com/kotlin/style-guide).
## Third-party tools
@ -55,8 +81,37 @@ This project aims to adhere to the [official Kotlin coding style](https://develo
> Please be aware that disclosing your secret recovery key to other software has security risks.
The [Seedvault backup parser](https://github.com/tlambertz/seedvault_backup_parser)
allows you to decrypt and inspect your backups.
allows you to decrypt and inspect your backups (version 0 backup).
It can also re-encrypt them.
The [Seedvault extractor](https://github.com/jackwilsdon/seedvault-extractor)
allows you to decrypt and inspect your backups from newer versions of Seedvault (version 1 backup).
It is currently work-in-progress.
## License
This application is available as open source under the terms of the [Apache-2.0 License](https://opensource.org/licenses/Apache-2.0).
This application is available as open source under the terms
of the [Apache-2.0 License](https://opensource.org/licenses/Apache-2.0).
## Funding
### Calyx Institute
This project is primarily developed and maintained by the [Calyx Institute](https://calyxinstitute.org/)
for usage in [CalyxOS](https://calyxos.org/).
### NGI0 PET Fund
This project was funded through the [NGI0 PET Fund](https://nlnet.nl/project/Seedvault/),
a fund established by [NLnet](https://nlnet.nl)
with financial support from the European Commission's Next Generation Internet programme,
under the aegis of DG Communications Networks, Content and Technology
under grant agreement No 825310.
### NGI0 Entrust Fund
This project was funded through the
[NGI0 Entrust Fund](https://nlnet.nl/project/SeedVault-Integrity/),
a fund established by [NLnet](https://nlnet.nl)
with financial support from the European Commission's Next Generation Internet programme,
under the aegis of DG Communications Networks, Content and Technology
under grant agreement No 101069594.

View file

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
SPDX-FileCopyrightText: 2017 Steve Soltys
SPDX-FileCopyrightText: 2020 The Calyx Institute
SPDX-License-Identifier: Apache-2.0
-->
<config>
<backup-transport-whitelisted-service
service="com.stevesoltys.seedvault/.transport.ConfigurableBackupTransportService" />
<hidden-api-whitelisted-app package="com.stevesoltys.seedvault" />
<!-- needed for storage backups launching foreground service from background -->
<allow-in-power-save package="com.stevesoltys.seedvault" />
</config>

View file

@ -1,194 +0,0 @@
import groovy.xml.XmlUtil
plugins {
id "com.android.application"
id "kotlin-android"
id "org.jlleitschuh.gradle.ktlint" version "9.4.0"
}
def gitDescribe = { ->
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'describe', '--always', '--tags', '--dirty=-dirty'
standardOutput = stdout
}
return stdout.toString().trim()
}
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig {
minSdkVersion 29 // leave at 29 for robolectric tests
targetSdkVersion rootProject.ext.targetSdkVersion
versionNameSuffix "-$gitDescribe"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
testInstrumentationRunnerArguments disableAnalytics: 'true'
}
buildTypes {
release {
minifyEnabled false
}
}
lintOptions {
disable "CheckedExceptions"
abortOnError true
}
compileOptions {
targetCompatibility 1.8
sourceCompatibility 1.8
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8.toString()
languageVersion = "1.3"
}
testOptions {
unitTests.all {
useJUnitPlatform()
testLogging {
events "passed", "skipped", "failed"
}
}
unitTests {
includeAndroidResources = true
}
}
sourceSets {
test {
java.srcDirs += "$projectDir/src/sharedTest/java"
}
androidTest {
java.srcDirs += "$projectDir/src/sharedTest/java"
}
}
signingConfigs {
aosp {
// Generated from the AOSP platform key:
// https://android.googlesource.com/platform/build/+/refs/tags/android-11.0.0_r29/target/product/security/platform.pk8
keyAlias "platform"
keyPassword "platform"
storeFile file("platform.jks")
storePassword "platform"
}
}
buildTypes.release.signingConfig = signingConfigs.aosp
buildTypes.debug.signingConfig = signingConfigs.aosp
}
dependencies {
compileOnly rootProject.ext.aosp_libs
/**
* Dependencies in AOSP
*
* We try to keep the dependencies in sync with what AOSP ships as Seedvault is meant to be built
* with the AOSP build system and gradle builds are just for more pleasant development.
* Using the AOSP versions in gradle builds allows us to spot issues early on.
*/
implementation rootProject.ext.kotlin_libs.std
// These coroutine libraries get upgraded otherwise to versions incompatible with kotlin version
implementation rootProject.ext.kotlin_libs.coroutines
implementation rootProject.ext.std_libs.androidx_core
// A newer version gets pulled in with AOSP via core, so we include fragment here explicitly
implementation rootProject.ext.std_libs.androidx_fragment
implementation rootProject.ext.std_libs.androidx_preference
implementation rootProject.ext.std_libs.androidx_lifecycle_viewmodel_ktx
implementation rootProject.ext.std_libs.androidx_lifecycle_livedata_ktx
implementation rootProject.ext.std_libs.androidx_constraintlayout
implementation rootProject.ext.std_libs.androidx_documentfile
implementation rootProject.ext.std_libs.com_google_android_material
/**
* Storage Dependencies
*/
implementation project(':storage:lib')
// implementation fileTree(include: ['storage.aar'], dir: "${rootProject.rootDir}/storage/lib/libs")
/**
* External Dependencies
*
* If the dependencies below are updated,
* please make sure to update the prebuilt libraries and the Android.bp files
* in the top-level `libs` folder to reflect that.
* You can copy these libraries from ~/.gradle/caches/modules-2
*/
// later versions than 2.1.1 require newer kotlin version
implementation fileTree(include: ['*.jar'], dir: "${rootProject.rootDir}/libs/koin-android")
implementation fileTree(include: ['*.aar'], dir: "${rootProject.rootDir}/libs/koin-android")
implementation fileTree(include: ['kotlin-bip39-1.0.2.jar'], dir: "${rootProject.rootDir}/libs")
/**
* Test Dependencies (do not concern the AOSP build)
*/
lintChecks rootProject.ext.lint_libs.exceptions
// anything less than 'implementation' fails tests run with gradlew
testImplementation rootProject.ext.aosp_libs
testImplementation 'androidx.test.ext:junit:1.1.2'
testImplementation('org.robolectric:robolectric:4.3.1') { // 4.4 has issue with non-idle Looper
// https://github.com/robolectric/robolectric/issues/5245
exclude group: "com.google.auto.service", module: "auto-service"
}
testImplementation "org.junit.jupiter:junit-jupiter-api:$junit5_version"
testImplementation "org.junit.jupiter:junit-jupiter-params:$junit5_version"
testImplementation "io.mockk:mockk:$mockk_version"
testImplementation 'org.bitcoinj:bitcoinj-core:0.15.10'
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junit5_version"
testRuntimeOnly "org.junit.vintage:junit-vintage-engine:$junit5_version"
androidTestImplementation 'androidx.test:runner:1.3.0'
androidTestImplementation 'androidx.test:rules:1.3.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation "io.mockk:mockk-android:$mockk_version"
}
apply from: "${rootProject.rootDir}/gradle/ktlint.gradle"
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
if (JavaVersion.current() >= JavaVersion.VERSION_1_9) {
options.compilerArgs.addAll(['--release', '8'])
}
options.compilerArgs.add('-Xbootclasspath/p:app/libs/android.jar:app/libs/libcore.jar')
}
}
// http://www.31mins.com/android-studio-build-system-application/
preBuild.doLast {
def imlFile = file(project.name + ".iml")
try {
def parsedXml = (new XmlParser()).parse(imlFile)
def jdkNode = parsedXml.component[1].orderEntry.find { it.'@type' == 'jdk' }
parsedXml.component[1].remove(jdkNode)
def apiString = android.compileSdkVersion.substring("android-".length())
def sdkString = "Android API " + apiString + " Platform"
//noinspection GroovyResultOfObjectAllocationIgnored // the note gets inserted
new Node(parsedXml.component[1], 'orderEntry', [
'type' : 'jdk',
'jdkName': sdkString,
'jdkType': 'Android SDK'
])
XmlUtil.serialize(parsedXml, new FileOutputStream(imlFile))
} catch (NullPointerException | FileNotFoundException ex) {
ex.printStackTrace()
}
}
configurations {
all {
resolutionStrategy {
failOnNonReproducibleResolution()
}
}
}

286
app/build.gradle.kts Normal file
View file

@ -0,0 +1,286 @@
//
// SPDX-FileCopyrightText: 2023 The Calyx Institute
// SPDX-License-Identifier: Apache-2.0
//
import com.google.protobuf.gradle.id
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import java.io.ByteArrayOutputStream
plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.jetbrains.kotlin.android)
alias(libs.plugins.google.protobuf)
}
val gitDescribe = {
val stdout = ByteArrayOutputStream()
exec {
commandLine("git", "describe", "--always", "--tags", "--dirty=-dirty")
standardOutput = stdout
}
stdout.toString().trim()
}
android {
namespace = "com.stevesoltys.seedvault"
compileSdk = libs.versions.compileSdk.get().toInt()
defaultConfig {
minSdk = libs.versions.minSdk.get().toInt()
targetSdk = libs.versions.targetSdk.get().toInt()
versionNameSuffix = "-${gitDescribe()}"
testInstrumentationRunner = "com.stevesoltys.seedvault.KoinInstrumentationTestRunner"
testInstrumentationRunnerArguments["disableAnalytics"] = "true"
}
signingConfigs {
create("aosp") {
// Generated from the AOSP platform key:
// https://android.googlesource.com/platform/build/+/refs/tags/android-11.0.0_r29/target/product/security/platform.pk8
keyAlias = "platform"
keyPassword = "platform"
storeFile = file("development/platform.jks")
storePassword = "platform"
}
}
buildTypes {
all {
isMinifyEnabled = false
}
getByName("release").signingConfig = signingConfigs.getByName("aosp")
getByName("debug").signingConfig = signingConfigs.getByName("aosp")
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_17.toString()
languageVersion = "1.8"
}
packaging {
resources {
excludes += listOf("META-INF/LICENSE.md", "META-INF/LICENSE-notice.md")
}
}
testOptions.unitTests {
all { it.useJUnitPlatform() }
isIncludeAndroidResources = true
}
sourceSets {
named("test") {
java.srcDirs("$projectDir/src/sharedTest/java")
}
named("androidTest") {
java.srcDirs("$projectDir/src/sharedTest/java")
}
}
protobuf {
protoc {
artifact = if ("aarch64" == System.getProperty("os.arch")) {
// mac m1
"com.google.protobuf:protoc:${libs.versions.protobuf.get()}:osx-x86_64"
} else {
// other
"com.google.protobuf:protoc:${libs.versions.protobuf.get()}"
}
}
generateProtoTasks {
all().forEach { task ->
task.plugins {
id("java") {
option("lite")
}
id("kotlin") {
option("lite")
}
}
}
}
}
lint {
abortOnError = true
disable.clear()
disable += setOf(
"DialogFragmentCallbacksDetector",
"InvalidFragmentVersionForActivityResult",
"CheckedExceptions"
)
}
}
dependencies {
val aospLibs: FileTree by rootProject.extra
compileOnly(aospLibs)
/**
* Dependencies in AOSP
*
* We try to keep the dependencies in sync with what AOSP ships as Seedvault is meant to be built
* with the AOSP build system and gradle builds are just for more pleasant development.
* Using the AOSP versions in gradle builds allows us to spot issues early on.
*/
implementation(libs.bundles.kotlin)
// These coroutine libraries get upgraded otherwise to versions incompatible with kotlin version
implementation(libs.bundles.coroutines)
implementation(libs.androidx.core)
// A newer version gets pulled in with AOSP via core, so we include fragment here explicitly
implementation(libs.androidx.fragment)
implementation(libs.androidx.activity)
implementation(libs.androidx.preference)
implementation(libs.androidx.lifecycle.viewmodel.ktx)
implementation(libs.androidx.lifecycle.livedata.ktx)
implementation(libs.androidx.constraintlayout)
implementation(libs.androidx.documentfile)
implementation(libs.androidx.work.runtime.ktx)
implementation(libs.google.material)
implementation(libs.google.protobuf.javalite)
implementation(libs.google.tink.android)
implementation(libs.kotlin.logging)
implementation(libs.squareup.okio)
/**
* Storage Dependencies
*/
implementation(project(":core"))
implementation(project(":storage:lib"))
/**
* External Dependencies
*
* If the dependencies below are updated,
* please make sure to update the prebuilt libraries and the Android.bp files
* in the top-level `libs` folder to reflect that.
* You can copy these libraries from ~/.gradle/caches/modules-2/files-2.1
*/
implementation(fileTree("${rootProject.rootDir}/libs/koin-android").include("*.jar"))
implementation(fileTree("${rootProject.rootDir}/libs/koin-android").include("*.aar"))
implementation(
fileTree("${rootProject.rootDir}/libs").include("protobuf-kotlin-lite-3.21.12.jar")
)
implementation(fileTree("${rootProject.rootDir}/libs").include("seedvault-chunker-0.1.jar"))
implementation(fileTree("${rootProject.rootDir}/libs").include("zstd-jni-1.5.6-5.aar"))
implementation(fileTree("${rootProject.rootDir}/libs").include("kotlin-bip39-jvm-1.0.8.jar"))
implementation(fileTree("${rootProject.rootDir}/libs").include("logback-android-3.0.0.aar"))
/**
* Test Dependencies (do not concern the AOSP build)
*/
lintChecks(libs.thirdegg.lint.rules)
// anything less than 'implementation' fails tests run with gradlew
testImplementation(aospLibs)
testImplementation("androidx.test.ext:junit:1.1.5")
testImplementation("org.slf4j:slf4j-simple:2.0.3")
testImplementation("org.robolectric:robolectric:4.12.2")
testImplementation("org.hamcrest:hamcrest:2.2")
testImplementation("org.junit.jupiter:junit-jupiter-api:${libs.versions.junit5.get()}")
testImplementation("org.junit.jupiter:junit-jupiter-params:${libs.versions.junit5.get()}")
testImplementation("io.mockk:mockk:${libs.versions.mockk.get()}")
testImplementation(
"org.jetbrains.kotlinx:kotlinx-coroutines-test:${libs.versions.coroutines.get()}"
)
testImplementation("app.cash.turbine:turbine:1.0.0")
testImplementation("org.bitcoinj:bitcoinj-core:0.16.2")
testImplementation("com.github.luben:zstd-jni:1.5.6-5")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:${libs.versions.junit5.get()}")
testRuntimeOnly("org.junit.vintage:junit-vintage-engine:${libs.versions.junit5.get()}")
androidTestImplementation(aospLibs)
androidTestImplementation(kotlin("test"))
androidTestImplementation("androidx.test:runner:1.4.0")
androidTestImplementation("androidx.test:rules:1.4.0")
androidTestImplementation("androidx.test.ext:junit:1.1.3")
androidTestImplementation("io.mockk:mockk-android:1.13.8")
androidTestImplementation("androidx.test.uiautomator:uiautomator:2.2.0")
}
gradle.projectsEvaluated {
tasks.withType(JavaCompile::class) {
options.compilerArgs.add("-Xbootclasspath/p:libs/aosp/android.jar:libs/aosp/libcore.jar")
}
}
tasks.withType<Test>().configureEach {
testLogging {
events("passed", "skipped", "failed")
showExceptions = true
showCauses = true
showStackTraces = true
exceptionFormat = TestExceptionFormat.FULL
}
}
configurations.all {
resolutionStrategy {
failOnNonReproducibleResolution()
}
}
tasks.register<Exec>("provisionEmulator") {
group = "emulator"
dependsOn(tasks.getByName("assembleRelease"))
doFirst {
commandLine(
"${project.projectDir}/development/scripts/provision_emulator.sh",
"seedvault",
"system-images;android-34;default;x86_64"
)
environment("ANDROID_HOME", android.sdkDirectory.absolutePath)
environment("JAVA_HOME", System.getProperty("java.home"))
}
}
tasks.register<Exec>("startEmulator") {
group = "emulator"
doFirst {
commandLine("${project.projectDir}/development/scripts/start_emulator.sh", "seedvault")
environment("ANDROID_HOME", android.sdkDirectory.absolutePath)
environment("JAVA_HOME", System.getProperty("java.home"))
}
}
tasks.register<Exec>("installEmulatorRelease") {
group = "emulator"
dependsOn(tasks.getByName("assembleRelease"))
doFirst {
commandLine("${project.projectDir}/development/scripts/install_app.sh")
environment("ANDROID_HOME", android.sdkDirectory.absolutePath)
environment("JAVA_HOME", System.getProperty("java.home"))
}
}
tasks.register<Exec>("clearEmulatorAppData") {
group = "emulator"
doFirst {
commandLine("${project.projectDir}/development/scripts/clear_app_data.sh")
environment("ANDROID_HOME", android.sdkDirectory.absolutePath)
environment("JAVA_HOME", System.getProperty("java.home"))
}
}

View file

@ -0,0 +1,950 @@
//Generated by the protocol buffer compiler. DO NOT EDIT!
// source: snapshot.proto
package com.stevesoltys.seedvault.proto;
@kotlin.jvm.JvmName("-initializesnapshot")
public inline fun snapshot(block: com.stevesoltys.seedvault.proto.SnapshotKt.Dsl.() -> kotlin.Unit): com.stevesoltys.seedvault.proto.Snapshot =
com.stevesoltys.seedvault.proto.SnapshotKt.Dsl._create(com.stevesoltys.seedvault.proto.Snapshot.newBuilder()).apply { block() }._build()
public object SnapshotKt {
@kotlin.OptIn(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)
@com.google.protobuf.kotlin.ProtoDslMarker
public class Dsl private constructor(
private val _builder: com.stevesoltys.seedvault.proto.Snapshot.Builder
) {
public companion object {
@kotlin.jvm.JvmSynthetic
@kotlin.PublishedApi
internal fun _create(builder: com.stevesoltys.seedvault.proto.Snapshot.Builder): Dsl = Dsl(builder)
}
@kotlin.jvm.JvmSynthetic
@kotlin.PublishedApi
internal fun _build(): com.stevesoltys.seedvault.proto.Snapshot = _builder.build()
/**
* <code>uint32 version = 1;</code>
*/
public var version: kotlin.Int
@JvmName("getVersion")
get() = _builder.getVersion()
@JvmName("setVersion")
set(value) {
_builder.setVersion(value)
}
/**
* <code>uint32 version = 1;</code>
*/
public fun clearVersion() {
_builder.clearVersion()
}
/**
* <code>uint64 token = 2;</code>
*/
public var token: kotlin.Long
@JvmName("getToken")
get() = _builder.getToken()
@JvmName("setToken")
set(value) {
_builder.setToken(value)
}
/**
* <code>uint64 token = 2;</code>
*/
public fun clearToken() {
_builder.clearToken()
}
/**
* <code>string name = 3;</code>
*/
public var name: kotlin.String
@JvmName("getName")
get() = _builder.getName()
@JvmName("setName")
set(value) {
_builder.setName(value)
}
/**
* <code>string name = 3;</code>
*/
public fun clearName() {
_builder.clearName()
}
/**
* <code>string user = 4;</code>
*/
public var user: kotlin.String
@JvmName("getUser")
get() = _builder.getUser()
@JvmName("setUser")
set(value) {
_builder.setUser(value)
}
/**
* <code>string user = 4;</code>
*/
public fun clearUser() {
_builder.clearUser()
}
/**
* <code>string androidId = 5;</code>
*/
public var androidId: kotlin.String
@JvmName("getAndroidId")
get() = _builder.getAndroidId()
@JvmName("setAndroidId")
set(value) {
_builder.setAndroidId(value)
}
/**
* <code>string androidId = 5;</code>
*/
public fun clearAndroidId() {
_builder.clearAndroidId()
}
/**
* <code>uint32 sdkInt = 6;</code>
*/
public var sdkInt: kotlin.Int
@JvmName("getSdkInt")
get() = _builder.getSdkInt()
@JvmName("setSdkInt")
set(value) {
_builder.setSdkInt(value)
}
/**
* <code>uint32 sdkInt = 6;</code>
*/
public fun clearSdkInt() {
_builder.clearSdkInt()
}
/**
* <code>string androidIncremental = 7;</code>
*/
public var androidIncremental: kotlin.String
@JvmName("getAndroidIncremental")
get() = _builder.getAndroidIncremental()
@JvmName("setAndroidIncremental")
set(value) {
_builder.setAndroidIncremental(value)
}
/**
* <code>string androidIncremental = 7;</code>
*/
public fun clearAndroidIncremental() {
_builder.clearAndroidIncremental()
}
/**
* <code>bool d2d = 8;</code>
*/
public var d2D: kotlin.Boolean
@JvmName("getD2D")
get() = _builder.getD2D()
@JvmName("setD2D")
set(value) {
_builder.setD2D(value)
}
/**
* <code>bool d2d = 8;</code>
*/
public fun clearD2D() {
_builder.clearD2D()
}
/**
* An uninstantiable, behaviorless type to represent the field in
* generics.
*/
@kotlin.OptIn(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)
public class AppsProxy private constructor() : com.google.protobuf.kotlin.DslProxy()
/**
* <code>map&lt;string, .com.stevesoltys.seedvault.proto.Snapshot.App&gt; apps = 9;</code>
*/
public val apps: com.google.protobuf.kotlin.DslMap<kotlin.String, com.stevesoltys.seedvault.proto.Snapshot.App, AppsProxy>
@kotlin.jvm.JvmSynthetic
@JvmName("getAppsMap")
get() = com.google.protobuf.kotlin.DslMap(
_builder.getAppsMap()
)
/**
* <code>map&lt;string, .com.stevesoltys.seedvault.proto.Snapshot.App&gt; apps = 9;</code>
*/
@JvmName("putApps")
public fun com.google.protobuf.kotlin.DslMap<kotlin.String, com.stevesoltys.seedvault.proto.Snapshot.App, AppsProxy>
.put(key: kotlin.String, value: com.stevesoltys.seedvault.proto.Snapshot.App) {
_builder.putApps(key, value)
}
/**
* <code>map&lt;string, .com.stevesoltys.seedvault.proto.Snapshot.App&gt; apps = 9;</code>
*/
@kotlin.jvm.JvmSynthetic
@JvmName("setApps")
@Suppress("NOTHING_TO_INLINE")
public inline operator fun com.google.protobuf.kotlin.DslMap<kotlin.String, com.stevesoltys.seedvault.proto.Snapshot.App, AppsProxy>
.set(key: kotlin.String, value: com.stevesoltys.seedvault.proto.Snapshot.App) {
put(key, value)
}
/**
* <code>map&lt;string, .com.stevesoltys.seedvault.proto.Snapshot.App&gt; apps = 9;</code>
*/
@kotlin.jvm.JvmSynthetic
@JvmName("removeApps")
public fun com.google.protobuf.kotlin.DslMap<kotlin.String, com.stevesoltys.seedvault.proto.Snapshot.App, AppsProxy>
.remove(key: kotlin.String) {
_builder.removeApps(key)
}
/**
* <code>map&lt;string, .com.stevesoltys.seedvault.proto.Snapshot.App&gt; apps = 9;</code>
*/
@kotlin.jvm.JvmSynthetic
@JvmName("putAllApps")
public fun com.google.protobuf.kotlin.DslMap<kotlin.String, com.stevesoltys.seedvault.proto.Snapshot.App, AppsProxy>
.putAll(map: kotlin.collections.Map<kotlin.String, com.stevesoltys.seedvault.proto.Snapshot.App>) {
_builder.putAllApps(map)
}
/**
* <code>map&lt;string, .com.stevesoltys.seedvault.proto.Snapshot.App&gt; apps = 9;</code>
*/
@kotlin.jvm.JvmSynthetic
@JvmName("clearApps")
public fun com.google.protobuf.kotlin.DslMap<kotlin.String, com.stevesoltys.seedvault.proto.Snapshot.App, AppsProxy>
.clear() {
_builder.clearApps()
}
/**
* An uninstantiable, behaviorless type to represent the field in
* generics.
*/
@kotlin.OptIn(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)
public class IconChunkIdsProxy private constructor() : com.google.protobuf.kotlin.DslProxy()
/**
* <code>repeated bytes iconChunkIds = 10;</code>
*/
public val iconChunkIds: com.google.protobuf.kotlin.DslList<com.google.protobuf.ByteString, IconChunkIdsProxy>
@kotlin.jvm.JvmSynthetic
get() = com.google.protobuf.kotlin.DslList(
_builder.getIconChunkIdsList()
)
/**
* <code>repeated bytes iconChunkIds = 10;</code>
* @param value The iconChunkIds to add.
*/
@kotlin.jvm.JvmSynthetic
@kotlin.jvm.JvmName("addIconChunkIds")
public fun com.google.protobuf.kotlin.DslList<com.google.protobuf.ByteString, IconChunkIdsProxy>.add(value: com.google.protobuf.ByteString) {
_builder.addIconChunkIds(value)
}/**
* <code>repeated bytes iconChunkIds = 10;</code>
* @param value The iconChunkIds to add.
*/
@kotlin.jvm.JvmSynthetic
@kotlin.jvm.JvmName("plusAssignIconChunkIds")
@Suppress("NOTHING_TO_INLINE")
public inline operator fun com.google.protobuf.kotlin.DslList<com.google.protobuf.ByteString, IconChunkIdsProxy>.plusAssign(value: com.google.protobuf.ByteString) {
add(value)
}/**
* <code>repeated bytes iconChunkIds = 10;</code>
* @param values The iconChunkIds to add.
*/
@kotlin.jvm.JvmSynthetic
@kotlin.jvm.JvmName("addAllIconChunkIds")
public fun com.google.protobuf.kotlin.DslList<com.google.protobuf.ByteString, IconChunkIdsProxy>.addAll(values: kotlin.collections.Iterable<com.google.protobuf.ByteString>) {
_builder.addAllIconChunkIds(values)
}/**
* <code>repeated bytes iconChunkIds = 10;</code>
* @param values The iconChunkIds to add.
*/
@kotlin.jvm.JvmSynthetic
@kotlin.jvm.JvmName("plusAssignAllIconChunkIds")
@Suppress("NOTHING_TO_INLINE")
public inline operator fun com.google.protobuf.kotlin.DslList<com.google.protobuf.ByteString, IconChunkIdsProxy>.plusAssign(values: kotlin.collections.Iterable<com.google.protobuf.ByteString>) {
addAll(values)
}/**
* <code>repeated bytes iconChunkIds = 10;</code>
* @param index The index to set the value at.
* @param value The iconChunkIds to set.
*/
@kotlin.jvm.JvmSynthetic
@kotlin.jvm.JvmName("setIconChunkIds")
public operator fun com.google.protobuf.kotlin.DslList<com.google.protobuf.ByteString, IconChunkIdsProxy>.set(index: kotlin.Int, value: com.google.protobuf.ByteString) {
_builder.setIconChunkIds(index, value)
}/**
* <code>repeated bytes iconChunkIds = 10;</code>
*/
@kotlin.jvm.JvmSynthetic
@kotlin.jvm.JvmName("clearIconChunkIds")
public fun com.google.protobuf.kotlin.DslList<com.google.protobuf.ByteString, IconChunkIdsProxy>.clear() {
_builder.clearIconChunkIds()
}
/**
* An uninstantiable, behaviorless type to represent the field in
* generics.
*/
@kotlin.OptIn(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)
public class BlobsProxy private constructor() : com.google.protobuf.kotlin.DslProxy()
/**
* <code>map&lt;string, .com.stevesoltys.seedvault.proto.Snapshot.Blob&gt; blobs = 11;</code>
*/
public val blobs: com.google.protobuf.kotlin.DslMap<kotlin.String, com.stevesoltys.seedvault.proto.Snapshot.Blob, BlobsProxy>
@kotlin.jvm.JvmSynthetic
@JvmName("getBlobsMap")
get() = com.google.protobuf.kotlin.DslMap(
_builder.getBlobsMap()
)
/**
* <code>map&lt;string, .com.stevesoltys.seedvault.proto.Snapshot.Blob&gt; blobs = 11;</code>
*/
@JvmName("putBlobs")
public fun com.google.protobuf.kotlin.DslMap<kotlin.String, com.stevesoltys.seedvault.proto.Snapshot.Blob, BlobsProxy>
.put(key: kotlin.String, value: com.stevesoltys.seedvault.proto.Snapshot.Blob) {
_builder.putBlobs(key, value)
}
/**
* <code>map&lt;string, .com.stevesoltys.seedvault.proto.Snapshot.Blob&gt; blobs = 11;</code>
*/
@kotlin.jvm.JvmSynthetic
@JvmName("setBlobs")
@Suppress("NOTHING_TO_INLINE")
public inline operator fun com.google.protobuf.kotlin.DslMap<kotlin.String, com.stevesoltys.seedvault.proto.Snapshot.Blob, BlobsProxy>
.set(key: kotlin.String, value: com.stevesoltys.seedvault.proto.Snapshot.Blob) {
put(key, value)
}
/**
* <code>map&lt;string, .com.stevesoltys.seedvault.proto.Snapshot.Blob&gt; blobs = 11;</code>
*/
@kotlin.jvm.JvmSynthetic
@JvmName("removeBlobs")
public fun com.google.protobuf.kotlin.DslMap<kotlin.String, com.stevesoltys.seedvault.proto.Snapshot.Blob, BlobsProxy>
.remove(key: kotlin.String) {
_builder.removeBlobs(key)
}
/**
* <code>map&lt;string, .com.stevesoltys.seedvault.proto.Snapshot.Blob&gt; blobs = 11;</code>
*/
@kotlin.jvm.JvmSynthetic
@JvmName("putAllBlobs")
public fun com.google.protobuf.kotlin.DslMap<kotlin.String, com.stevesoltys.seedvault.proto.Snapshot.Blob, BlobsProxy>
.putAll(map: kotlin.collections.Map<kotlin.String, com.stevesoltys.seedvault.proto.Snapshot.Blob>) {
_builder.putAllBlobs(map)
}
/**
* <code>map&lt;string, .com.stevesoltys.seedvault.proto.Snapshot.Blob&gt; blobs = 11;</code>
*/
@kotlin.jvm.JvmSynthetic
@JvmName("clearBlobs")
public fun com.google.protobuf.kotlin.DslMap<kotlin.String, com.stevesoltys.seedvault.proto.Snapshot.Blob, BlobsProxy>
.clear() {
_builder.clearBlobs()
}
}
@kotlin.jvm.JvmName("-initializeapp")
public inline fun app(block: com.stevesoltys.seedvault.proto.SnapshotKt.AppKt.Dsl.() -> kotlin.Unit): com.stevesoltys.seedvault.proto.Snapshot.App =
com.stevesoltys.seedvault.proto.SnapshotKt.AppKt.Dsl._create(com.stevesoltys.seedvault.proto.Snapshot.App.newBuilder()).apply { block() }._build()
public object AppKt {
@kotlin.OptIn(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)
@com.google.protobuf.kotlin.ProtoDslMarker
public class Dsl private constructor(
private val _builder: com.stevesoltys.seedvault.proto.Snapshot.App.Builder
) {
public companion object {
@kotlin.jvm.JvmSynthetic
@kotlin.PublishedApi
internal fun _create(builder: com.stevesoltys.seedvault.proto.Snapshot.App.Builder): Dsl = Dsl(builder)
}
@kotlin.jvm.JvmSynthetic
@kotlin.PublishedApi
internal fun _build(): com.stevesoltys.seedvault.proto.Snapshot.App = _builder.build()
/**
* <code>uint64 time = 1;</code>
*/
public var time: kotlin.Long
@JvmName("getTime")
get() = _builder.getTime()
@JvmName("setTime")
set(value) {
_builder.setTime(value)
}
/**
* <code>uint64 time = 1;</code>
*/
public fun clearTime() {
_builder.clearTime()
}
/**
* <code>.com.stevesoltys.seedvault.proto.Snapshot.BackupType type = 2;</code>
*/
public var type: com.stevesoltys.seedvault.proto.Snapshot.BackupType
@JvmName("getType")
get() = _builder.getType()
@JvmName("setType")
set(value) {
_builder.setType(value)
}
/**
* <code>.com.stevesoltys.seedvault.proto.Snapshot.BackupType type = 2;</code>
*/
public fun clearType() {
_builder.clearType()
}
/**
* <code>string name = 3;</code>
*/
public var name: kotlin.String
@JvmName("getName")
get() = _builder.getName()
@JvmName("setName")
set(value) {
_builder.setName(value)
}
/**
* <code>string name = 3;</code>
*/
public fun clearName() {
_builder.clearName()
}
/**
* <code>bool system = 4;</code>
*/
public var system: kotlin.Boolean
@JvmName("getSystem")
get() = _builder.getSystem()
@JvmName("setSystem")
set(value) {
_builder.setSystem(value)
}
/**
* <code>bool system = 4;</code>
*/
public fun clearSystem() {
_builder.clearSystem()
}
/**
* <code>bool launchableSystemApp = 5;</code>
*/
public var launchableSystemApp: kotlin.Boolean
@JvmName("getLaunchableSystemApp")
get() = _builder.getLaunchableSystemApp()
@JvmName("setLaunchableSystemApp")
set(value) {
_builder.setLaunchableSystemApp(value)
}
/**
* <code>bool launchableSystemApp = 5;</code>
*/
public fun clearLaunchableSystemApp() {
_builder.clearLaunchableSystemApp()
}
/**
* An uninstantiable, behaviorless type to represent the field in
* generics.
*/
@kotlin.OptIn(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)
public class ChunkIdsProxy private constructor() : com.google.protobuf.kotlin.DslProxy()
/**
* <code>repeated bytes chunkIds = 6;</code>
*/
public val chunkIds: com.google.protobuf.kotlin.DslList<com.google.protobuf.ByteString, ChunkIdsProxy>
@kotlin.jvm.JvmSynthetic
get() = com.google.protobuf.kotlin.DslList(
_builder.getChunkIdsList()
)
/**
* <code>repeated bytes chunkIds = 6;</code>
* @param value The chunkIds to add.
*/
@kotlin.jvm.JvmSynthetic
@kotlin.jvm.JvmName("addChunkIds")
public fun com.google.protobuf.kotlin.DslList<com.google.protobuf.ByteString, ChunkIdsProxy>.add(value: com.google.protobuf.ByteString) {
_builder.addChunkIds(value)
}/**
* <code>repeated bytes chunkIds = 6;</code>
* @param value The chunkIds to add.
*/
@kotlin.jvm.JvmSynthetic
@kotlin.jvm.JvmName("plusAssignChunkIds")
@Suppress("NOTHING_TO_INLINE")
public inline operator fun com.google.protobuf.kotlin.DslList<com.google.protobuf.ByteString, ChunkIdsProxy>.plusAssign(value: com.google.protobuf.ByteString) {
add(value)
}/**
* <code>repeated bytes chunkIds = 6;</code>
* @param values The chunkIds to add.
*/
@kotlin.jvm.JvmSynthetic
@kotlin.jvm.JvmName("addAllChunkIds")
public fun com.google.protobuf.kotlin.DslList<com.google.protobuf.ByteString, ChunkIdsProxy>.addAll(values: kotlin.collections.Iterable<com.google.protobuf.ByteString>) {
_builder.addAllChunkIds(values)
}/**
* <code>repeated bytes chunkIds = 6;</code>
* @param values The chunkIds to add.
*/
@kotlin.jvm.JvmSynthetic
@kotlin.jvm.JvmName("plusAssignAllChunkIds")
@Suppress("NOTHING_TO_INLINE")
public inline operator fun com.google.protobuf.kotlin.DslList<com.google.protobuf.ByteString, ChunkIdsProxy>.plusAssign(values: kotlin.collections.Iterable<com.google.protobuf.ByteString>) {
addAll(values)
}/**
* <code>repeated bytes chunkIds = 6;</code>
* @param index The index to set the value at.
* @param value The chunkIds to set.
*/
@kotlin.jvm.JvmSynthetic
@kotlin.jvm.JvmName("setChunkIds")
public operator fun com.google.protobuf.kotlin.DslList<com.google.protobuf.ByteString, ChunkIdsProxy>.set(index: kotlin.Int, value: com.google.protobuf.ByteString) {
_builder.setChunkIds(index, value)
}/**
* <code>repeated bytes chunkIds = 6;</code>
*/
@kotlin.jvm.JvmSynthetic
@kotlin.jvm.JvmName("clearChunkIds")
public fun com.google.protobuf.kotlin.DslList<com.google.protobuf.ByteString, ChunkIdsProxy>.clear() {
_builder.clearChunkIds()
}
/**
* <code>.com.stevesoltys.seedvault.proto.Snapshot.Apk apk = 7;</code>
*/
public var apk: com.stevesoltys.seedvault.proto.Snapshot.Apk
@JvmName("getApk")
get() = _builder.getApk()
@JvmName("setApk")
set(value) {
_builder.setApk(value)
}
/**
* <code>.com.stevesoltys.seedvault.proto.Snapshot.Apk apk = 7;</code>
*/
public fun clearApk() {
_builder.clearApk()
}
/**
* <code>.com.stevesoltys.seedvault.proto.Snapshot.Apk apk = 7;</code>
* @return Whether the apk field is set.
*/
public fun hasApk(): kotlin.Boolean {
return _builder.hasApk()
}
/**
* <code>uint64 size = 8;</code>
*/
public var size: kotlin.Long
@JvmName("getSize")
get() = _builder.getSize()
@JvmName("setSize")
set(value) {
_builder.setSize(value)
}
/**
* <code>uint64 size = 8;</code>
*/
public fun clearSize() {
_builder.clearSize()
}
}
}
@kotlin.jvm.JvmName("-initializeapk")
public inline fun apk(block: com.stevesoltys.seedvault.proto.SnapshotKt.ApkKt.Dsl.() -> kotlin.Unit): com.stevesoltys.seedvault.proto.Snapshot.Apk =
com.stevesoltys.seedvault.proto.SnapshotKt.ApkKt.Dsl._create(com.stevesoltys.seedvault.proto.Snapshot.Apk.newBuilder()).apply { block() }._build()
public object ApkKt {
@kotlin.OptIn(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)
@com.google.protobuf.kotlin.ProtoDslMarker
public class Dsl private constructor(
private val _builder: com.stevesoltys.seedvault.proto.Snapshot.Apk.Builder
) {
public companion object {
@kotlin.jvm.JvmSynthetic
@kotlin.PublishedApi
internal fun _create(builder: com.stevesoltys.seedvault.proto.Snapshot.Apk.Builder): Dsl = Dsl(builder)
}
@kotlin.jvm.JvmSynthetic
@kotlin.PublishedApi
internal fun _build(): com.stevesoltys.seedvault.proto.Snapshot.Apk = _builder.build()
/**
* <pre>
**
* Attention: Has default value of 0
* </pre>
*
* <code>uint64 versionCode = 1;</code>
*/
public var versionCode: kotlin.Long
@JvmName("getVersionCode")
get() = _builder.getVersionCode()
@JvmName("setVersionCode")
set(value) {
_builder.setVersionCode(value)
}
/**
* <pre>
**
* Attention: Has default value of 0
* </pre>
*
* <code>uint64 versionCode = 1;</code>
*/
public fun clearVersionCode() {
_builder.clearVersionCode()
}
/**
* <code>string installer = 2;</code>
*/
public var installer: kotlin.String
@JvmName("getInstaller")
get() = _builder.getInstaller()
@JvmName("setInstaller")
set(value) {
_builder.setInstaller(value)
}
/**
* <code>string installer = 2;</code>
*/
public fun clearInstaller() {
_builder.clearInstaller()
}
/**
* An uninstantiable, behaviorless type to represent the field in
* generics.
*/
@kotlin.OptIn(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)
public class SignaturesProxy private constructor() : com.google.protobuf.kotlin.DslProxy()
/**
* <code>repeated bytes signatures = 3;</code>
*/
public val signatures: com.google.protobuf.kotlin.DslList<com.google.protobuf.ByteString, SignaturesProxy>
@kotlin.jvm.JvmSynthetic
get() = com.google.protobuf.kotlin.DslList(
_builder.getSignaturesList()
)
/**
* <code>repeated bytes signatures = 3;</code>
* @param value The signatures to add.
*/
@kotlin.jvm.JvmSynthetic
@kotlin.jvm.JvmName("addSignatures")
public fun com.google.protobuf.kotlin.DslList<com.google.protobuf.ByteString, SignaturesProxy>.add(value: com.google.protobuf.ByteString) {
_builder.addSignatures(value)
}/**
* <code>repeated bytes signatures = 3;</code>
* @param value The signatures to add.
*/
@kotlin.jvm.JvmSynthetic
@kotlin.jvm.JvmName("plusAssignSignatures")
@Suppress("NOTHING_TO_INLINE")
public inline operator fun com.google.protobuf.kotlin.DslList<com.google.protobuf.ByteString, SignaturesProxy>.plusAssign(value: com.google.protobuf.ByteString) {
add(value)
}/**
* <code>repeated bytes signatures = 3;</code>
* @param values The signatures to add.
*/
@kotlin.jvm.JvmSynthetic
@kotlin.jvm.JvmName("addAllSignatures")
public fun com.google.protobuf.kotlin.DslList<com.google.protobuf.ByteString, SignaturesProxy>.addAll(values: kotlin.collections.Iterable<com.google.protobuf.ByteString>) {
_builder.addAllSignatures(values)
}/**
* <code>repeated bytes signatures = 3;</code>
* @param values The signatures to add.
*/
@kotlin.jvm.JvmSynthetic
@kotlin.jvm.JvmName("plusAssignAllSignatures")
@Suppress("NOTHING_TO_INLINE")
public inline operator fun com.google.protobuf.kotlin.DslList<com.google.protobuf.ByteString, SignaturesProxy>.plusAssign(values: kotlin.collections.Iterable<com.google.protobuf.ByteString>) {
addAll(values)
}/**
* <code>repeated bytes signatures = 3;</code>
* @param index The index to set the value at.
* @param value The signatures to set.
*/
@kotlin.jvm.JvmSynthetic
@kotlin.jvm.JvmName("setSignatures")
public operator fun com.google.protobuf.kotlin.DslList<com.google.protobuf.ByteString, SignaturesProxy>.set(index: kotlin.Int, value: com.google.protobuf.ByteString) {
_builder.setSignatures(index, value)
}/**
* <code>repeated bytes signatures = 3;</code>
*/
@kotlin.jvm.JvmSynthetic
@kotlin.jvm.JvmName("clearSignatures")
public fun com.google.protobuf.kotlin.DslList<com.google.protobuf.ByteString, SignaturesProxy>.clear() {
_builder.clearSignatures()
}
/**
* An uninstantiable, behaviorless type to represent the field in
* generics.
*/
@kotlin.OptIn(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)
public class SplitsProxy private constructor() : com.google.protobuf.kotlin.DslProxy()
/**
* <code>repeated .com.stevesoltys.seedvault.proto.Snapshot.Split splits = 4;</code>
*/
public val splits: com.google.protobuf.kotlin.DslList<com.stevesoltys.seedvault.proto.Snapshot.Split, SplitsProxy>
@kotlin.jvm.JvmSynthetic
get() = com.google.protobuf.kotlin.DslList(
_builder.getSplitsList()
)
/**
* <code>repeated .com.stevesoltys.seedvault.proto.Snapshot.Split splits = 4;</code>
* @param value The splits to add.
*/
@kotlin.jvm.JvmSynthetic
@kotlin.jvm.JvmName("addSplits")
public fun com.google.protobuf.kotlin.DslList<com.stevesoltys.seedvault.proto.Snapshot.Split, SplitsProxy>.add(value: com.stevesoltys.seedvault.proto.Snapshot.Split) {
_builder.addSplits(value)
}
/**
* <code>repeated .com.stevesoltys.seedvault.proto.Snapshot.Split splits = 4;</code>
* @param value The splits to add.
*/
@kotlin.jvm.JvmSynthetic
@kotlin.jvm.JvmName("plusAssignSplits")
@Suppress("NOTHING_TO_INLINE")
public inline operator fun com.google.protobuf.kotlin.DslList<com.stevesoltys.seedvault.proto.Snapshot.Split, SplitsProxy>.plusAssign(value: com.stevesoltys.seedvault.proto.Snapshot.Split) {
add(value)
}
/**
* <code>repeated .com.stevesoltys.seedvault.proto.Snapshot.Split splits = 4;</code>
* @param values The splits to add.
*/
@kotlin.jvm.JvmSynthetic
@kotlin.jvm.JvmName("addAllSplits")
public fun com.google.protobuf.kotlin.DslList<com.stevesoltys.seedvault.proto.Snapshot.Split, SplitsProxy>.addAll(values: kotlin.collections.Iterable<com.stevesoltys.seedvault.proto.Snapshot.Split>) {
_builder.addAllSplits(values)
}
/**
* <code>repeated .com.stevesoltys.seedvault.proto.Snapshot.Split splits = 4;</code>
* @param values The splits to add.
*/
@kotlin.jvm.JvmSynthetic
@kotlin.jvm.JvmName("plusAssignAllSplits")
@Suppress("NOTHING_TO_INLINE")
public inline operator fun com.google.protobuf.kotlin.DslList<com.stevesoltys.seedvault.proto.Snapshot.Split, SplitsProxy>.plusAssign(values: kotlin.collections.Iterable<com.stevesoltys.seedvault.proto.Snapshot.Split>) {
addAll(values)
}
/**
* <code>repeated .com.stevesoltys.seedvault.proto.Snapshot.Split splits = 4;</code>
* @param index The index to set the value at.
* @param value The splits to set.
*/
@kotlin.jvm.JvmSynthetic
@kotlin.jvm.JvmName("setSplits")
public operator fun com.google.protobuf.kotlin.DslList<com.stevesoltys.seedvault.proto.Snapshot.Split, SplitsProxy>.set(index: kotlin.Int, value: com.stevesoltys.seedvault.proto.Snapshot.Split) {
_builder.setSplits(index, value)
}
/**
* <code>repeated .com.stevesoltys.seedvault.proto.Snapshot.Split splits = 4;</code>
*/
@kotlin.jvm.JvmSynthetic
@kotlin.jvm.JvmName("clearSplits")
public fun com.google.protobuf.kotlin.DslList<com.stevesoltys.seedvault.proto.Snapshot.Split, SplitsProxy>.clear() {
_builder.clearSplits()
}
}
}
@kotlin.jvm.JvmName("-initializesplit")
public inline fun split(block: com.stevesoltys.seedvault.proto.SnapshotKt.SplitKt.Dsl.() -> kotlin.Unit): com.stevesoltys.seedvault.proto.Snapshot.Split =
com.stevesoltys.seedvault.proto.SnapshotKt.SplitKt.Dsl._create(com.stevesoltys.seedvault.proto.Snapshot.Split.newBuilder()).apply { block() }._build()
public object SplitKt {
@kotlin.OptIn(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)
@com.google.protobuf.kotlin.ProtoDslMarker
public class Dsl private constructor(
private val _builder: com.stevesoltys.seedvault.proto.Snapshot.Split.Builder
) {
public companion object {
@kotlin.jvm.JvmSynthetic
@kotlin.PublishedApi
internal fun _create(builder: com.stevesoltys.seedvault.proto.Snapshot.Split.Builder): Dsl = Dsl(builder)
}
@kotlin.jvm.JvmSynthetic
@kotlin.PublishedApi
internal fun _build(): com.stevesoltys.seedvault.proto.Snapshot.Split = _builder.build()
/**
* <code>string name = 1;</code>
*/
public var name: kotlin.String
@JvmName("getName")
get() = _builder.getName()
@JvmName("setName")
set(value) {
_builder.setName(value)
}
/**
* <code>string name = 1;</code>
*/
public fun clearName() {
_builder.clearName()
}
/**
* An uninstantiable, behaviorless type to represent the field in
* generics.
*/
@kotlin.OptIn(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)
public class ChunkIdsProxy private constructor() : com.google.protobuf.kotlin.DslProxy()
/**
* <code>repeated bytes chunkIds = 2;</code>
*/
public val chunkIds: com.google.protobuf.kotlin.DslList<com.google.protobuf.ByteString, ChunkIdsProxy>
@kotlin.jvm.JvmSynthetic
get() = com.google.protobuf.kotlin.DslList(
_builder.getChunkIdsList()
)
/**
* <code>repeated bytes chunkIds = 2;</code>
* @param value The chunkIds to add.
*/
@kotlin.jvm.JvmSynthetic
@kotlin.jvm.JvmName("addChunkIds")
public fun com.google.protobuf.kotlin.DslList<com.google.protobuf.ByteString, ChunkIdsProxy>.add(value: com.google.protobuf.ByteString) {
_builder.addChunkIds(value)
}/**
* <code>repeated bytes chunkIds = 2;</code>
* @param value The chunkIds to add.
*/
@kotlin.jvm.JvmSynthetic
@kotlin.jvm.JvmName("plusAssignChunkIds")
@Suppress("NOTHING_TO_INLINE")
public inline operator fun com.google.protobuf.kotlin.DslList<com.google.protobuf.ByteString, ChunkIdsProxy>.plusAssign(value: com.google.protobuf.ByteString) {
add(value)
}/**
* <code>repeated bytes chunkIds = 2;</code>
* @param values The chunkIds to add.
*/
@kotlin.jvm.JvmSynthetic
@kotlin.jvm.JvmName("addAllChunkIds")
public fun com.google.protobuf.kotlin.DslList<com.google.protobuf.ByteString, ChunkIdsProxy>.addAll(values: kotlin.collections.Iterable<com.google.protobuf.ByteString>) {
_builder.addAllChunkIds(values)
}/**
* <code>repeated bytes chunkIds = 2;</code>
* @param values The chunkIds to add.
*/
@kotlin.jvm.JvmSynthetic
@kotlin.jvm.JvmName("plusAssignAllChunkIds")
@Suppress("NOTHING_TO_INLINE")
public inline operator fun com.google.protobuf.kotlin.DslList<com.google.protobuf.ByteString, ChunkIdsProxy>.plusAssign(values: kotlin.collections.Iterable<com.google.protobuf.ByteString>) {
addAll(values)
}/**
* <code>repeated bytes chunkIds = 2;</code>
* @param index The index to set the value at.
* @param value The chunkIds to set.
*/
@kotlin.jvm.JvmSynthetic
@kotlin.jvm.JvmName("setChunkIds")
public operator fun com.google.protobuf.kotlin.DslList<com.google.protobuf.ByteString, ChunkIdsProxy>.set(index: kotlin.Int, value: com.google.protobuf.ByteString) {
_builder.setChunkIds(index, value)
}/**
* <code>repeated bytes chunkIds = 2;</code>
*/
@kotlin.jvm.JvmSynthetic
@kotlin.jvm.JvmName("clearChunkIds")
public fun com.google.protobuf.kotlin.DslList<com.google.protobuf.ByteString, ChunkIdsProxy>.clear() {
_builder.clearChunkIds()
}}
}
@kotlin.jvm.JvmName("-initializeblob")
public inline fun blob(block: com.stevesoltys.seedvault.proto.SnapshotKt.BlobKt.Dsl.() -> kotlin.Unit): com.stevesoltys.seedvault.proto.Snapshot.Blob =
com.stevesoltys.seedvault.proto.SnapshotKt.BlobKt.Dsl._create(com.stevesoltys.seedvault.proto.Snapshot.Blob.newBuilder()).apply { block() }._build()
public object BlobKt {
@kotlin.OptIn(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)
@com.google.protobuf.kotlin.ProtoDslMarker
public class Dsl private constructor(
private val _builder: com.stevesoltys.seedvault.proto.Snapshot.Blob.Builder
) {
public companion object {
@kotlin.jvm.JvmSynthetic
@kotlin.PublishedApi
internal fun _create(builder: com.stevesoltys.seedvault.proto.Snapshot.Blob.Builder): Dsl = Dsl(builder)
}
@kotlin.jvm.JvmSynthetic
@kotlin.PublishedApi
internal fun _build(): com.stevesoltys.seedvault.proto.Snapshot.Blob = _builder.build()
/**
* <code>bytes id = 1;</code>
*/
public var id: com.google.protobuf.ByteString
@JvmName("getId")
get() = _builder.getId()
@JvmName("setId")
set(value) {
_builder.setId(value)
}
/**
* <code>bytes id = 1;</code>
*/
public fun clearId() {
_builder.clearId()
}
/**
* <code>uint32 length = 2;</code>
*/
public var length: kotlin.Int
@JvmName("getLength")
get() = _builder.getLength()
@JvmName("setLength")
set(value) {
_builder.setLength(value)
}
/**
* <code>uint32 length = 2;</code>
*/
public fun clearLength() {
_builder.clearLength()
}
/**
* <code>uint32 uncompressedLength = 3;</code>
*/
public var uncompressedLength: kotlin.Int
@JvmName("getUncompressedLength")
get() = _builder.getUncompressedLength()
@JvmName("setUncompressedLength")
set(value) {
_builder.setUncompressedLength(value)
}
/**
* <code>uint32 uncompressedLength = 3;</code>
*/
public fun clearUncompressedLength() {
_builder.clearUncompressedLength()
}
}
}
}
public inline fun com.stevesoltys.seedvault.proto.Snapshot.copy(block: com.stevesoltys.seedvault.proto.SnapshotKt.Dsl.() -> kotlin.Unit): com.stevesoltys.seedvault.proto.Snapshot =
com.stevesoltys.seedvault.proto.SnapshotKt.Dsl._create(this.toBuilder()).apply { block() }._build()
public inline fun com.stevesoltys.seedvault.proto.Snapshot.App.copy(block: com.stevesoltys.seedvault.proto.SnapshotKt.AppKt.Dsl.() -> kotlin.Unit): com.stevesoltys.seedvault.proto.Snapshot.App =
com.stevesoltys.seedvault.proto.SnapshotKt.AppKt.Dsl._create(this.toBuilder()).apply { block() }._build()
public val com.stevesoltys.seedvault.proto.Snapshot.AppOrBuilder.apkOrNull: com.stevesoltys.seedvault.proto.Snapshot.Apk?
get() = if (hasApk()) getApk() else null
public inline fun com.stevesoltys.seedvault.proto.Snapshot.Apk.copy(block: com.stevesoltys.seedvault.proto.SnapshotKt.ApkKt.Dsl.() -> kotlin.Unit): com.stevesoltys.seedvault.proto.Snapshot.Apk =
com.stevesoltys.seedvault.proto.SnapshotKt.ApkKt.Dsl._create(this.toBuilder()).apply { block() }._build()
public inline fun com.stevesoltys.seedvault.proto.Snapshot.Split.copy(block: com.stevesoltys.seedvault.proto.SnapshotKt.SplitKt.Dsl.() -> kotlin.Unit): com.stevesoltys.seedvault.proto.Snapshot.Split =
com.stevesoltys.seedvault.proto.SnapshotKt.SplitKt.Dsl._create(this.toBuilder()).apply { block() }._build()
public inline fun com.stevesoltys.seedvault.proto.Snapshot.Blob.copy(block: com.stevesoltys.seedvault.proto.SnapshotKt.BlobKt.Dsl.() -> kotlin.Unit): com.stevesoltys.seedvault.proto.Snapshot.Blob =
com.stevesoltys.seedvault.proto.SnapshotKt.BlobKt.Dsl._create(this.toBuilder()).apply { block() }._build()

View file

@ -0,0 +1,50 @@
# Development
## Using an emulator
It is possible to install and run Seedvault in an emulator. This is likely the path of least resistance, since you don't need to build AOSP from source to make and test code changes.
It's also helpful for quickly testing Seedvault on newer versions of Android.
Please note that this process has only been tested on Linux.
### Setup
After opening the project in Android Studio, try running the `app:provisionEmulator` Gradle task.
This task runs the script in `scripts/provision_emulator.sh`:
```bash
./app/development/scripts/provision_emulator.sh "seedvault" "system-images;android-33;google_apis;x86_64"
```
### Starting the emulator
You should use the Gradle task `app:startEmulator` to develop with the emulator. This is to ensure
the `-writable-system` flag is set when the emulator starts (required to install Seedvault).
This task runs the script in `scripts/start_emulator.sh`:
```bash
./app/development/scripts/start_emulator.sh "seedvault"
```
### Testing changes
Once the emulator is provisioned and running, you should be able to use the `app:installEmulatorRelease`
Gradle task to install updates.
This task depends on `app:assembleRelease` and runs the script in `scripts/install_app.sh`:
```bash
./app/development/scripts/install_app.sh
```
There's also an Android Studio [runtime configuration](https://developer.android.com/studio/run/rundebugconfig) `app-emulator` which will build, install, and automatically launch the `com.stevesoltys.seedvault.settings.SettingsActivity` as if you clicked `Backup` in settings.
### Notes
The `MANAGE_DOCUMENTS` permission will not be granted unless you are using a base AOSP
image. Currently by default we are using the `google-apis` version of the image, which does not provide the
permission because it is not signed with the test platform key.
The [generic AOSP images](https://developer.android.com/topic/generic-system-image/releases) are signed with the test platform key, but at the time of writing there is no AOSP emulator image for Android 13 in the default SDK manager repositories.

View file

@ -0,0 +1,26 @@
#!/usr/bin/env bash
#
# SPDX-FileCopyrightText: 2023 The Calyx Institute
# SPDX-License-Identifier: Apache-2.0
#
# assert ANDROID_HOME is set
if [ -z "$ANDROID_HOME" ]; then
echo "ANDROID_HOME is not set"
exit 1
fi
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
DEVELOPMENT_DIR=$SCRIPT_DIR/..
ROOT_PROJECT_DIR=$SCRIPT_DIR/../../..
EMULATOR_DEVICE_NAME=$($ANDROID_HOME/platform-tools/adb devices | grep emulator | cut -f1)
if [ -z "$EMULATOR_DEVICE_NAME" ]; then
echo "Emulator device name not found"
exit 1
fi
ADB="$ANDROID_HOME/platform-tools/adb -s $EMULATOR_DEVICE_NAME"
$ADB shell pm clear com.stevesoltys.seedvault

View file

@ -0,0 +1,36 @@
#!/usr/bin/env bash
#
# SPDX-FileCopyrightText: 2023 The Calyx Institute
# SPDX-License-Identifier: Apache-2.0
#
# assert ANDROID_HOME is set
if [ -z "$ANDROID_HOME" ]; then
echo "ANDROID_HOME is not set"
exit 1
fi
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
ROOT_PROJECT_DIR=$SCRIPT_DIR/../../..
EMULATOR_DEVICE_NAME=$("$ANDROID_HOME"/platform-tools/adb devices | grep emulator | cut -f1)
if [ -z "$EMULATOR_DEVICE_NAME" ]; then
echo "Emulator device name not found"
exit 1
fi
ADB="$ANDROID_HOME/platform-tools/adb -s $EMULATOR_DEVICE_NAME"
$ADB root
sleep 3 # wait for adb to restart
$ADB remount # remount /system as writable
echo "Installing Seedvault app..."
$ADB shell mkdir -p /system/priv-app/Seedvault
$ADB push "$ROOT_PROJECT_DIR"/app/build/outputs/apk/release/app-release.apk /system/priv-app/Seedvault/Seedvault.apk
echo "Installing Seedvault permissions..."
$ADB push "$ROOT_PROJECT_DIR"/permissions_com.stevesoltys.seedvault.xml /system/etc/permissions/privapp-permissions-seedvault.xml
$ADB push "$ROOT_PROJECT_DIR"/allowlist_com.stevesoltys.seedvault.xml /system/etc/sysconfig/allowlist-seedvault.xml
$ADB shell am broadcast -a android.intent.action.BOOT_COMPLETED

View file

@ -0,0 +1,103 @@
#!/usr/bin/env bash
#
# SPDX-FileCopyrightText: 2023 The Calyx Institute
# SPDX-License-Identifier: Apache-2.0
#
# assert ANDROID_HOME is set
if [ -z "$ANDROID_HOME" ]; then
echo "ANDROID_HOME is not set"
exit 1
fi
# assert 2 parameters are provided
if [ $# -ne 2 ]; then
echo "Usage: $0 <emulator_name> <system_image>"
exit 1
fi
EMULATOR_NAME=$1
SYSTEM_IMAGE=$2
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
echo "Downloading system image..."
yes | "$ANDROID_HOME"/cmdline-tools/latest/bin/sdkmanager --install "$SYSTEM_IMAGE"
# create AVD if it doesn't exist
if "$ANDROID_HOME"/cmdline-tools/latest/bin/avdmanager list avd | grep -q "$EMULATOR_NAME"; then
echo "AVD already exists. Skipping creation."
else
echo "Creating AVD..."
echo 'no' | "$ANDROID_HOME"/cmdline-tools/latest/bin/avdmanager create avd -n "$EMULATOR_NAME" -k "$SYSTEM_IMAGE"
sleep 1
fi
EMULATOR_DEVICE_NAME=$("$ANDROID_HOME"/platform-tools/adb devices | grep emulator | cut -f1)
if [ -z "$EMULATOR_DEVICE_NAME" ]; then
"$SCRIPT_DIR"/start_emulator.sh "$EMULATOR_NAME"
fi
# wait for emulator device to appear with 180 second timeout
echo "Waiting for emulator device..."
for i in {1..180}; do
if [ -z "$EMULATOR_DEVICE_NAME" ]; then
sleep 1
EMULATOR_DEVICE_NAME=$("$ANDROID_HOME"/platform-tools/adb devices | grep emulator | cut -f1)
else
break
fi
done
if [ -z "$EMULATOR_DEVICE_NAME" ]; then
echo "Emulator device name not found"
exit 1
fi
ADB="$ANDROID_HOME/platform-tools/adb -s $EMULATOR_DEVICE_NAME"
echo "Waiting for emulator to boot..."
$ADB wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done;'
echo "Provisioning emulator for write access to '/system'..."
$ADB root
sleep 3 # wait for adb to restart
$ADB remount # remount /system as writable
echo "Rebooting emulator..."
$ADB reboot # need to reboot first time we remount
$ADB wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done;'
echo "Provisioning emulator for Seedvault..."
"$SCRIPT_DIR"/install_app.sh
echo "Rebooting emulator..."
$ADB reboot
$ADB wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done;'
echo "Disabling backup..."
$ADB shell bmgr enable false
echo "Downloading and extracting test backup to '/sdcard/seedvault_baseline'..."
if [ ! -f backup.tar.gz ]; then
echo "Downloading test backup..."
wget --quiet https://github.com/seedvault-app/seedvault-test-data/releases/download/3/backup.tar.gz
fi
$ADB root
sleep 3 # wait for adb to restart
$ADB push backup.tar.gz /sdcard
rm backup.tar.gz
$ADB wait-for-device
$ADB shell mkdir -p /sdcard/seedvault_baseline
$ADB shell tar xzf /sdcard/backup.tar.gz --directory=/sdcard/seedvault_baseline
$ADB shell rm /sdcard/backup.tar.gz
# sometimes a system dialog (e.g. launcher stopped) is showing and taking focus
$ADB shell am broadcast -a android.intent.action.CLOSE_SYSTEM_DIALOGS
echo "Emulator '$EMULATOR_NAME' has been provisioned with Seedvault!"

View file

@ -0,0 +1,22 @@
#!/usr/bin/env bash
#
# SPDX-FileCopyrightText: 2023 The Calyx Institute
# SPDX-License-Identifier: Apache-2.0
#
# assert ANDROID_HOME is set
if [ -z "$ANDROID_HOME" ]; then
echo "ANDROID_HOME is not set"
exit 1
fi
# assert 1 parameter is provided
if [ $# -ne 1 ]; then
echo "Usage: $0 <emulator_name>"
exit 1
fi
EMULATOR_NAME=$1
echo "Starting emulator..."
nohup $ANDROID_HOME/emulator/emulator -avd "$EMULATOR_NAME" -gpu swiftshader_indirect -writable-system >/dev/null 2>&1 &

Binary file not shown.

View file

@ -1,4 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
SPDX-FileCopyrightText: 2020 The Calyx Institute
SPDX-License-Identifier: Apache-2.0
-->
<lint>
<issue id="MissingTranslation" severity="ignore" />
<issue id="ExtraTranslation" severity="ignore" />
</lint>

View file

@ -1,6 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.stevesoltys.seedvault">
<!--
SPDX-FileCopyrightText: 2020 The Calyx Institute
SPDX-License-Identifier: Apache-2.0
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application android:extractNativeLibs="true" />
</manifest>

View file

@ -1,33 +0,0 @@
package com.stevesoltys.seedvault
import android.util.Log
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.LargeTest
import com.stevesoltys.seedvault.crypto.CipherFactoryImpl
import com.stevesoltys.seedvault.crypto.KeyManagerTestImpl
import org.junit.Assert.assertTrue
import org.junit.Test
import org.junit.runner.RunWith
private val TAG = CipherUniqueNonceTest::class.java.simpleName
private const val ITERATIONS = 1_000_000
@LargeTest
@RunWith(AndroidJUnit4::class)
class CipherUniqueNonceTest {
private val keyManager = KeyManagerTestImpl()
private val cipherFactory = CipherFactoryImpl(keyManager)
private val nonceSet = HashSet<ByteArray>()
@Test
fun testUniqueNonce() {
for (i in 1..ITERATIONS) {
val iv = cipherFactory.createEncryptionCipher().iv
Log.w(TAG, "$i: ${iv.toHexString()}")
assertTrue(nonceSet.add(iv))
}
}
}

View file

@ -0,0 +1,83 @@
/*
* SPDX-FileCopyrightText: 2023 The Calyx Institute
* SPDX-License-Identifier: Apache-2.0
*/
package com.stevesoltys.seedvault
import com.stevesoltys.seedvault.restore.RestoreViewModel
import com.stevesoltys.seedvault.settings.SettingsManager
import com.stevesoltys.seedvault.transport.backup.FullBackup
import com.stevesoltys.seedvault.transport.backup.InputFactory
import com.stevesoltys.seedvault.transport.backup.KVBackup
import com.stevesoltys.seedvault.transport.backup.PackageService
import com.stevesoltys.seedvault.transport.restore.FullRestore
import com.stevesoltys.seedvault.transport.restore.KVRestore
import com.stevesoltys.seedvault.transport.restore.OutputFactory
import com.stevesoltys.seedvault.ui.notification.BackupNotificationManager
import com.stevesoltys.seedvault.ui.storage.BackupStorageViewModel
import com.stevesoltys.seedvault.ui.storage.RestoreStorageViewModel
import io.mockk.spyk
import org.koin.androidx.viewmodel.dsl.viewModel
import org.koin.core.module.Module
import org.koin.dsl.module
internal var currentRestoreViewModel: RestoreViewModel? = null
internal var currentBackupStorageViewModel: BackupStorageViewModel? = null
internal var currentRestoreStorageViewModel: RestoreStorageViewModel? = null
class KoinInstrumentationTestApp : App() {
override fun appModules(): List<Module> {
val testModule = module {
val context = this@KoinInstrumentationTestApp
single { spyk(PackageService(context, get(), get())) }
single { spyk(SettingsManager(context)) }
single { spyk(BackupNotificationManager(context)) }
single { spyk(FullBackup(get(), get(), get(), get())) }
single { spyk(KVBackup(get(), get(), get())) }
single { spyk(InputFactory()) }
single { spyk(FullRestore(get(), get(), get(), get(), get(), get())) }
single { spyk(KVRestore(get(), get(), get(), get(), get(), get(), get())) }
single { spyk(OutputFactory()) }
viewModel {
currentRestoreViewModel =
spyk(
RestoreViewModel(
app = context,
settingsManager = get(),
keyManager = get(),
backupManager = get(),
restoreCoordinator = get(),
appBackupManager = get(),
apkRestore = get(),
iconManager = get(),
storageBackup = get(),
backendManager = get(),
fileSelectionManager = get(),
)
)
currentRestoreViewModel!!
}
viewModel {
val viewModel =
BackupStorageViewModel(context, get(), get(), get(), get(), get(), get(), get())
currentBackupStorageViewModel = spyk(viewModel)
currentBackupStorageViewModel!!
}
viewModel {
currentRestoreStorageViewModel =
spyk(RestoreStorageViewModel(context, get(), get(), get(), get()))
currentRestoreStorageViewModel!!
}
}
return super.appModules().plus(testModule)
}
}

View file

@ -0,0 +1,25 @@
/*
* SPDX-FileCopyrightText: 2023 The Calyx Institute
* SPDX-License-Identifier: Apache-2.0
*/
package com.stevesoltys.seedvault
import android.app.Application
import android.content.Context
import androidx.test.runner.AndroidJUnitRunner
class KoinInstrumentationTestRunner : AndroidJUnitRunner() {
override fun newApplication(
classLoader: ClassLoader?,
className: String?,
context: Context?,
): Application {
return super.newApplication(
classLoader,
KoinInstrumentationTestApp::class.java.name,
context
)
}
}

View file

@ -1,87 +1,84 @@
/*
* SPDX-FileCopyrightText: 2020 The Calyx Institute
* SPDX-License-Identifier: Apache-2.0
*/
package com.stevesoltys.seedvault
import androidx.test.core.content.pm.PackageInfoBuilder
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.MediumTest
import androidx.test.platform.app.InstrumentationRegistry
import com.stevesoltys.seedvault.plugins.saf.DocumentsProviderBackupPlugin
import com.stevesoltys.seedvault.plugins.saf.DocumentsProviderFullBackup
import com.stevesoltys.seedvault.plugins.saf.DocumentsProviderFullRestorePlugin
import com.stevesoltys.seedvault.plugins.saf.DocumentsProviderKVBackup
import com.stevesoltys.seedvault.plugins.saf.DocumentsProviderKVRestorePlugin
import com.stevesoltys.seedvault.plugins.saf.DocumentsProviderRestorePlugin
import com.stevesoltys.seedvault.plugins.saf.DocumentsStorage
import com.stevesoltys.seedvault.plugins.saf.MAX_KEY_LENGTH
import com.stevesoltys.seedvault.plugins.saf.MAX_KEY_LENGTH_NEXTCLOUD
import com.stevesoltys.seedvault.plugins.saf.deleteContents
import com.stevesoltys.seedvault.backend.LegacyStoragePlugin
import com.stevesoltys.seedvault.backend.saf.DocumentsProviderLegacyPlugin
import com.stevesoltys.seedvault.backend.saf.DocumentsStorage
import com.stevesoltys.seedvault.settings.SettingsManager
import com.stevesoltys.seedvault.transport.backup.BackupPlugin
import com.stevesoltys.seedvault.transport.backup.FullBackupPlugin
import com.stevesoltys.seedvault.transport.backup.KVBackupPlugin
import com.stevesoltys.seedvault.transport.restore.FullRestorePlugin
import com.stevesoltys.seedvault.transport.restore.KVRestorePlugin
import com.stevesoltys.seedvault.transport.restore.RestorePlugin
import io.mockk.every
import io.mockk.mockk
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.runBlocking
import org.calyxos.seedvault.core.backends.LegacyAppBackupFile
import org.calyxos.seedvault.core.backends.saf.SafBackend
import org.junit.After
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertTrue
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.koin.core.KoinComponent
import org.koin.core.inject
import java.io.IOException
import kotlin.random.Random
import org.koin.core.component.KoinComponent
import org.koin.core.component.inject
@RunWith(AndroidJUnit4::class)
@Suppress("BlockingMethodInNonBlockingContext")
@MediumTest
class PluginTest : KoinComponent {
private val context = InstrumentationRegistry.getInstrumentation().targetContext
private val settingsManager: SettingsManager by inject()
private val mockedSettingsManager: SettingsManager = mockk()
private val storage = DocumentsStorage(context, mockedSettingsManager)
private val kvBackupPlugin: KVBackupPlugin = DocumentsProviderKVBackup(context, storage)
private val fullBackupPlugin: FullBackupPlugin = DocumentsProviderFullBackup(context, storage)
private val backupPlugin: BackupPlugin = DocumentsProviderBackupPlugin(
context,
storage,
kvBackupPlugin,
fullBackupPlugin
private val storage = DocumentsStorage(
appContext = context,
safStorage = settingsManager.getSafProperties() ?: error("No SAF storage"),
)
private val kvRestorePlugin: KVRestorePlugin =
DocumentsProviderKVRestorePlugin(context, storage)
private val fullRestorePlugin: FullRestorePlugin =
DocumentsProviderFullRestorePlugin(context, storage)
private val restorePlugin: RestorePlugin =
DocumentsProviderRestorePlugin(context, storage, kvRestorePlugin, fullRestorePlugin)
private val backend = SafBackend(context, storage.safStorage)
private val token = Random.nextLong()
@Suppress("Deprecation")
private val legacyStoragePlugin: LegacyStoragePlugin = DocumentsProviderLegacyPlugin(context) {
storage
}
private val token = System.currentTimeMillis() - 365L * 24L * 60L * 60L * 1000L
private val packageInfo = PackageInfoBuilder.newBuilder().setPackageName("org.example").build()
private val packageInfo2 = PackageInfoBuilder.newBuilder().setPackageName("net.example").build()
@Before
fun setup() = runBlocking {
every { mockedSettingsManager.getStorage() } returns settingsManager.getStorage()
storage.rootBackupDir?.deleteContents(context)
?: error("Select a storage location in the app first!")
every {
mockedSettingsManager.getSafProperties()
} returns settingsManager.getSafProperties()
backend.removeAll()
}
@After
fun tearDown() = runBlocking {
storage.rootBackupDir?.deleteContents(context)
Unit
backend.removeAll()
}
@Test
fun testProviderPackageName() {
assertNotNull(backupPlugin.providerPackageName)
assertNotNull(backend.providerPackageName)
}
@Test
fun testTest() = runBlocking(Dispatchers.IO) {
assertTrue(backend.test())
}
@Test
fun testGetFreeSpace() = runBlocking(Dispatchers.IO) {
val freeBytes = backend.getFreeSpace() ?: error("no free space retrieved")
assertTrue(freeBytes > 0)
}
/**
@ -94,260 +91,116 @@ class PluginTest : KoinComponent {
@Test
fun testInitializationAndRestoreSets() = runBlocking(Dispatchers.IO) {
// no backups available initially
assertEquals(0, restorePlugin.getAvailableBackups()?.toList()?.size)
val uri = settingsManager.getStorage()?.getDocumentFile(context)?.uri ?: error("no storage")
assertFalse(restorePlugin.hasBackup(uri))
assertEquals(0, backend.getAvailableBackupFileHandles().toList().size)
// prepare returned tokens requested when initializing device
every { mockedSettingsManager.getToken() } returnsMany listOf(token, token + 1, token + 1)
// start new restore set and initialize device afterwards
backupPlugin.startNewRestoreSet(token)
backupPlugin.initializeDevice()
every { mockedSettingsManager.token } returnsMany listOf(token, token + 1, token + 1)
// write metadata (needed for backup to be recognized)
backupPlugin.getMetadataOutputStream().writeAndClose(getRandomByteArray())
backend.save(LegacyAppBackupFile.Metadata(token))
.writeAndClose(getRandomByteArray())
// one backup available now
assertEquals(1, restorePlugin.getAvailableBackups()?.toList()?.size)
assertTrue(restorePlugin.hasBackup(uri))
assertEquals(1, backend.getAvailableBackupFileHandles().toList().size)
// initializing again (with another restore set) does add a restore set
backupPlugin.startNewRestoreSet(token + 1)
backupPlugin.initializeDevice()
backupPlugin.getMetadataOutputStream().writeAndClose(getRandomByteArray())
assertEquals(2, restorePlugin.getAvailableBackups()?.toList()?.size)
assertTrue(restorePlugin.hasBackup(uri))
backend.save(LegacyAppBackupFile.Metadata(token + 1))
.writeAndClose(getRandomByteArray())
assertEquals(2, backend.getAvailableBackupFileHandles().toList().size)
// initializing again (without new restore set) doesn't change number of restore sets
backupPlugin.initializeDevice()
backupPlugin.getMetadataOutputStream().writeAndClose(getRandomByteArray())
assertEquals(2, restorePlugin.getAvailableBackups()?.toList()?.size)
// ensure that the new backup dirs exist
assertTrue(storage.currentKvBackupDir!!.exists())
assertTrue(storage.currentFullBackupDir!!.exists())
backend.save(LegacyAppBackupFile.Metadata(token + 1))
.writeAndClose(getRandomByteArray())
assertEquals(2, backend.getAvailableBackupFileHandles().toList().size)
}
@Test
fun testMetadataWriteRead() = runBlocking(Dispatchers.IO) {
every { mockedSettingsManager.getToken() } returns token
backupPlugin.startNewRestoreSet(token)
backupPlugin.initializeDevice()
every { mockedSettingsManager.token } returns token
// write metadata
val metadata = getRandomByteArray()
backupPlugin.getMetadataOutputStream().writeAndClose(metadata)
backend.save(LegacyAppBackupFile.Metadata(token)).writeAndClose(metadata)
// get available backups, expect only one with our token and no error
var availableBackups = restorePlugin.getAvailableBackups()?.toList()
check(availableBackups != null)
var availableBackups = backend.getAvailableBackupFileHandles().toList()
assertEquals(1, availableBackups.size)
assertEquals(token, availableBackups[0].token)
assertFalse(availableBackups[0].error)
var backupHandle = availableBackups[0] as LegacyAppBackupFile.Metadata
assertEquals(token, backupHandle.token)
// read metadata matches what was written earlier
assertReadEquals(metadata, availableBackups[0].inputStream)
assertReadEquals(metadata, backend.load(backupHandle))
// initializing again (without changing storage) keeps restore set with same token
backupPlugin.initializeDevice()
backupPlugin.getMetadataOutputStream().writeAndClose(metadata)
availableBackups = restorePlugin.getAvailableBackups()?.toList()
check(availableBackups != null)
backend.save(LegacyAppBackupFile.Metadata(token)).writeAndClose(metadata)
availableBackups = backend.getAvailableBackupFileHandles().toList()
assertEquals(1, availableBackups.size)
assertEquals(token, availableBackups[0].token)
assertFalse(availableBackups[0].error)
backupHandle = availableBackups[0] as LegacyAppBackupFile.Metadata
assertEquals(token, backupHandle.token)
// metadata hasn't changed
assertReadEquals(metadata, availableBackups[0].inputStream)
assertReadEquals(metadata, backend.load(backupHandle))
}
@Test
fun testApkWriteRead() = runBlocking {
fun v0testApkWriteRead() = runBlocking {
// initialize storage with given token
initStorage(token)
// write random bytes as APK
val apk1 = getRandomByteArray(1337 * 1024)
backupPlugin.getApkOutputStream(packageInfo, "").writeAndClose(apk1)
backend.save(LegacyAppBackupFile.Blob(token, "${packageInfo.packageName}.apk"))
.writeAndClose(apk1)
// assert that read APK bytes match what was written
assertReadEquals(apk1, restorePlugin.getApkInputStream(token, packageInfo.packageName, ""))
assertReadEquals(
apk1,
legacyStoragePlugin.getApkInputStream(token, packageInfo.packageName, "")
)
// write random bytes as another APK
val suffix2 = getRandomBase64(23)
val apk2 = getRandomByteArray(23 * 1024 * 1024)
backupPlugin.getApkOutputStream(packageInfo2, suffix2).writeAndClose(apk2)
backend.save(LegacyAppBackupFile.Blob(token, "${packageInfo2.packageName}$suffix2.apk"))
.writeAndClose(apk2)
// assert that read APK bytes match what was written
assertReadEquals(
apk2,
restorePlugin.getApkInputStream(token, packageInfo2.packageName, suffix2)
legacyStoragePlugin.getApkInputStream(token, packageInfo2.packageName, suffix2)
)
}
@Test
fun testKvBackupRestore() = runBlocking {
// define shortcuts
val kvBackup = backupPlugin.kvBackupPlugin
val kvRestore = restorePlugin.kvRestorePlugin
fun testBackupRestore() = runBlocking {
// initialize storage with given token
initStorage(token)
// no data available for given package
assertFalse(kvBackup.hasDataForPackage(packageInfo))
assertFalse(kvRestore.hasDataForPackage(token, packageInfo))
// define key/value pair records
val record1 = Pair(getRandomBase64(23), getRandomByteArray(1337))
val record2 = Pair(getRandomBase64(42), getRandomByteArray(42 * 1024))
val record3 = Pair(getRandomBase64(128), getRandomByteArray(5 * 1024 * 1024))
// write first record
kvBackup.getOutputStreamForRecord(packageInfo, record1.first).writeAndClose(record1.second)
// data is now available for current token and given package, but not for different token
assertTrue(kvBackup.hasDataForPackage(packageInfo))
assertTrue(kvRestore.hasDataForPackage(token, packageInfo))
assertFalse(kvRestore.hasDataForPackage(token + 1, packageInfo))
// record for package is found and returned properly
var records = kvRestore.listRecords(token, packageInfo)
assertEquals(1, records.size)
assertEquals(record1.first, records[0])
assertReadEquals(
record1.second,
kvRestore.getInputStreamForRecord(token, packageInfo, record1.first)
)
// write second and third record
kvBackup.getOutputStreamForRecord(packageInfo, record2.first).writeAndClose(record2.second)
kvBackup.getOutputStreamForRecord(packageInfo, record3.first).writeAndClose(record3.second)
// all records for package are found and returned properly
assertTrue(kvRestore.hasDataForPackage(token, packageInfo))
records = kvRestore.listRecords(token, packageInfo)
assertEquals(listOf(record1.first, record2.first, record3.first).sorted(), records.sorted())
assertReadEquals(
record1.second,
kvRestore.getInputStreamForRecord(token, packageInfo, record1.first)
)
assertReadEquals(
record2.second,
kvRestore.getInputStreamForRecord(token, packageInfo, record2.first)
)
assertReadEquals(
record3.second,
kvRestore.getInputStreamForRecord(token, packageInfo, record3.first)
)
// delete record3 and ensure that the other two are still found
kvBackup.deleteRecord(packageInfo, record3.first)
assertTrue(kvRestore.hasDataForPackage(token, packageInfo))
records = kvRestore.listRecords(token, packageInfo)
assertEquals(listOf(record1.first, record2.first).sorted(), records.sorted())
// remove all data of package and ensure that it is gone
kvBackup.removeDataOfPackage(packageInfo)
assertFalse(kvBackup.hasDataForPackage(packageInfo))
assertFalse(kvRestore.hasDataForPackage(token, packageInfo))
}
@Test
fun testMaxKvKeyLength() = runBlocking {
// define shortcuts
val kvBackup = backupPlugin.kvBackupPlugin
val kvRestore = restorePlugin.kvRestorePlugin
// initialize storage with given token
initStorage(token)
assertFalse(kvBackup.hasDataForPackage(packageInfo))
// FIXME get Nextcloud to have the same limit
// Since Nextcloud is using WebDAV and that seems to have undefined lower file name limits
// we might have to lower our maximum to accommodate for that.
val max = if (isNextcloud()) MAX_KEY_LENGTH_NEXTCLOUD else MAX_KEY_LENGTH
val maxOver = if (isNextcloud()) max + 10 else max + 1
// define record with maximum key length and one above the maximum
val recordMax = Pair(getRandomBase64(max), getRandomByteArray(1024))
val recordOver = Pair(getRandomBase64(maxOver), getRandomByteArray(1024))
// write max record
kvBackup.getOutputStreamForRecord(packageInfo, recordMax.first)
.writeAndClose(recordMax.second)
// max record is found correctly
assertTrue(kvRestore.hasDataForPackage(token, packageInfo))
val records = kvRestore.listRecords(token, packageInfo)
assertEquals(listOf(recordMax.first), records)
// write exceeding key length record
if (isNextcloud()) {
// Nextcloud simply refuses to write long filenames
coAssertThrows(IOException::class.java) {
kvBackup.getOutputStreamForRecord(packageInfo, recordOver.first)
.writeAndClose(recordOver.second)
}
} else {
coAssertThrows(IllegalStateException::class.java) {
kvBackup.getOutputStreamForRecord(packageInfo, recordOver.first)
.writeAndClose(recordOver.second)
}
}
}
@Test
fun testFullBackupRestore() = runBlocking {
// define shortcuts
val fullBackup = backupPlugin.fullBackupPlugin
val fullRestore = restorePlugin.fullRestorePlugin
// initialize storage with given token
initStorage(token)
// no data available initially
assertFalse(fullRestore.hasDataForPackage(token, packageInfo))
assertFalse(fullRestore.hasDataForPackage(token, packageInfo2))
val name1 = getRandomBase64()
val name2 = getRandomBase64()
// write full backup data
val data = getRandomByteArray(5 * 1024 * 1024)
fullBackup.getOutputStream(packageInfo).writeAndClose(data)
// data is available now, but only this token
assertTrue(fullRestore.hasDataForPackage(token, packageInfo))
assertFalse(fullRestore.hasDataForPackage(token + 1, packageInfo))
backend.save(LegacyAppBackupFile.Blob(token, name1)).writeAndClose(data)
// restore data matches backed up data
assertReadEquals(data, fullRestore.getInputStreamForPackage(token, packageInfo))
assertReadEquals(data, backend.load(LegacyAppBackupFile.Blob(token, name1)))
// write and check data for second package
val data2 = getRandomByteArray(5 * 1024 * 1024)
fullBackup.getOutputStream(packageInfo2).writeAndClose(data2)
assertTrue(fullRestore.hasDataForPackage(token, packageInfo2))
assertReadEquals(data2, fullRestore.getInputStreamForPackage(token, packageInfo2))
backend.save(LegacyAppBackupFile.Blob(token, name2)).writeAndClose(data2)
assertReadEquals(data2, backend.load(LegacyAppBackupFile.Blob(token, name2)))
// remove data of first package again and ensure that no more data is found
fullBackup.removeDataOfPackage(packageInfo)
assertFalse(fullRestore.hasDataForPackage(token, packageInfo))
// second package is still there
assertTrue(fullRestore.hasDataForPackage(token, packageInfo2))
backend.remove(LegacyAppBackupFile.Blob(token, name1))
// ensure that it gets deleted as well
fullBackup.removeDataOfPackage(packageInfo2)
assertFalse(fullRestore.hasDataForPackage(token, packageInfo2))
backend.remove(LegacyAppBackupFile.Blob(token, name2))
}
private fun initStorage(token: Long) = runBlocking {
every { mockedSettingsManager.getToken() } returns token
backupPlugin.initializeDevice()
}
private fun isNextcloud(): Boolean {
return backupPlugin.providerPackageName?.startsWith("com.nextcloud") ?: false
every { mockedSettingsManager.token } returns token
}
}

View file

@ -0,0 +1,44 @@
/*
* SPDX-FileCopyrightText: 2024 The Calyx Institute
* SPDX-License-Identifier: Apache-2.0
*/
package com.stevesoltys.seedvault.backend.saf
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.MediumTest
import androidx.test.platform.app.InstrumentationRegistry
import com.stevesoltys.seedvault.settings.SettingsManager
import kotlinx.coroutines.runBlocking
import org.calyxos.seedvault.core.backends.Backend
import org.calyxos.seedvault.core.backends.BackendTest
import org.calyxos.seedvault.core.backends.saf.SafBackend
import org.junit.Test
import org.junit.runner.RunWith
import org.koin.core.component.KoinComponent
import org.koin.core.component.inject
@RunWith(AndroidJUnit4::class)
@MediumTest
class SafBackendTest : BackendTest(), KoinComponent {
private val context = InstrumentationRegistry.getInstrumentation().targetContext
private val settingsManager by inject<SettingsManager>()
private val safProperties = settingsManager.getSafProperties() ?: error("No SAF storage")
override val backend: Backend = SafBackend(context, safProperties, ".SeedvaultTest")
@Test
fun `test write list read rename delete`(): Unit = runBlocking {
testWriteListReadRenameDelete()
}
@Test
fun `test remove create write file`(): Unit = runBlocking {
testRemoveCreateWriteFile()
}
@Test
fun `test free space and create app blob without root folder`(): Unit = runBlocking {
testTestFreeSpaceAndCreateBlob()
}
}

View file

@ -0,0 +1,209 @@
/*
* SPDX-FileCopyrightText: 2023 The Calyx Institute
* SPDX-License-Identifier: Apache-2.0
*/
package com.stevesoltys.seedvault.e2e
import android.content.pm.PackageInfo
import android.os.ParcelFileDescriptor
import androidx.test.uiautomator.Until
import com.stevesoltys.seedvault.e2e.io.BackupDataInputIntercept
import com.stevesoltys.seedvault.e2e.screen.impl.BackupScreen
import com.stevesoltys.seedvault.transport.backup.FullBackup
import com.stevesoltys.seedvault.transport.backup.InputFactory
import com.stevesoltys.seedvault.transport.backup.KVBackup
import com.stevesoltys.seedvault.ui.notification.BackupNotificationManager
import io.mockk.clearMocks
import io.mockk.coEvery
import io.mockk.every
import kotlinx.coroutines.delay
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withTimeout
import org.calyxos.seedvault.core.toHexString
import org.koin.core.component.get
import java.security.DigestInputStream
import java.security.MessageDigest
import java.util.concurrent.atomic.AtomicBoolean
import kotlin.test.fail
internal interface LargeBackupTestBase : LargeTestBase {
companion object {
private const val BACKUP_TIMEOUT = 360 * 1000L
}
val spyBackupNotificationManager: BackupNotificationManager get() = get()
val spyFullBackup: FullBackup get() = get()
val spyKVBackup: KVBackup get() = get()
val spyInputFactory: InputFactory get() = get()
fun launchBackupActivity() {
runCommand("am start -n ${targetContext.packageName}/.settings.SettingsActivity")
waitUntilIdle()
}
fun startBackup() {
BackupScreen {
if (!backupManager.isBackupEnabled) {
backupSwitch.click()
waitUntilIdle()
BackupScreen {
device.wait(Until.hasObject(initializingText), 10000)
device.wait(Until.gone(initializingText), 120000)
}
}
backupMenu.clickAndWaitForNewWindow()
waitUntilIdle()
backupNowButton.clickAndWaitForNewWindow()
waitUntilIdle()
backupStatusButton.clickAndWaitForNewWindow()
waitUntilIdle()
}
}
fun performBackup(): SeedvaultLargeTestResult {
val backupResult = SeedvaultLargeTestResult(
full = mutableMapOf(),
kv = mutableMapOf(),
userApps = packageService.userApps,
)
val completed = spyOnBackup(backupResult)
startBackup()
waitForBackupResult(completed)
return backupResult.copy(
backupResults = backupResult.allUserApps().associate {
it.packageName to spyMetadataManager.getPackageMetadata(it.packageName)
}.toMutableMap()
)
}
private fun waitForBackupResult(completed: AtomicBoolean) {
runBlocking {
withTimeout(BACKUP_TIMEOUT) {
while (!completed.get()) {
delay(100)
}
}
}
}
private fun spyOnBackup(backupResult: SeedvaultLargeTestResult): AtomicBoolean {
clearMocks(spyInputFactory, spyKVBackup, spyFullBackup)
spyOnFullBackupData(backupResult)
spyOnKVBackupData(backupResult)
return spyOnBackupCompletion()
}
private fun spyOnKVBackupData(backupResult: SeedvaultLargeTestResult) {
var packageName: String? = null
var data = mutableMapOf<String, ByteArray>()
coEvery {
spyKVBackup.performBackup(any(), any(), any())
} answers {
packageName = firstArg<PackageInfo>().packageName
callOriginal()
}
every {
spyInputFactory.getBackupDataInput(any())
} answers {
val fd = firstArg<ParcelFileDescriptor>().fileDescriptor
BackupDataInputIntercept(fd) { key, value ->
data[key] = value
}
}
coEvery {
spyKVBackup.finishBackup()
} answers {
val oldMap = HashMap<String, String>()
// @pm@ and android can get backed up multiple times (if we need more than one request)
// so we need to keep the data it backed up before
if (backupResult.kv.containsKey(packageName)) {
backupResult.kv[packageName]?.forEach { (key, value) ->
// if a key existing in new data, we use its value from new data, don't override
if (!data.containsKey(key)) oldMap[key] = value
}
}
backupResult.kv[packageName!!] = data
.mapValues { entry -> entry.value.sha256() }
.toMutableMap()
.apply {
putAll(oldMap)
}
packageName = null
data = mutableMapOf()
callOriginal()
}
}
private fun spyOnFullBackupData(backupResult: SeedvaultLargeTestResult) {
var packageName: String? = null
val messageDigest = MessageDigest.getInstance("SHA-256")
var digestInputStream: DigestInputStream? = null
coEvery {
spyFullBackup.performFullBackup(any(), any(), any())
} answers {
packageName = firstArg<PackageInfo>().packageName
callOriginal()
}
every {
spyInputFactory.getInputStream(any())
} answers {
digestInputStream = DigestInputStream(callOriginal(), messageDigest)
digestInputStream!!
}
coEvery {
spyFullBackup.finishBackup()
} answers {
val result = callOriginal()
val digest = digestInputStream?.messageDigest ?: fail("No digestInputStream")
backupResult.full[packageName!!] = digest.digest().toHexString()
packageName = null
digest.reset()
result
}
}
private fun spyOnBackupCompletion(): AtomicBoolean {
val completed = AtomicBoolean(false)
clearMocks(spyBackupNotificationManager)
every {
spyBackupNotificationManager.onBackupSuccess(any(), any(), any())
} answers {
callOriginal()
completed.set(true)
}
every {
spyBackupNotificationManager.onBackupError()
} answers {
callOriginal()
completed.set(true)
fail("Backup failed.")
}
return completed
}
}

View file

@ -0,0 +1,259 @@
/*
* SPDX-FileCopyrightText: 2023 The Calyx Institute
* SPDX-License-Identifier: Apache-2.0
*/
package com.stevesoltys.seedvault.e2e
import android.content.pm.PackageInfo
import android.os.ParcelFileDescriptor
import com.stevesoltys.seedvault.e2e.io.BackupDataOutputIntercept
import com.stevesoltys.seedvault.e2e.screen.impl.RecoveryCodeScreen
import com.stevesoltys.seedvault.e2e.screen.impl.RestoreScreen
import com.stevesoltys.seedvault.transport.restore.FullRestore
import com.stevesoltys.seedvault.transport.restore.KVRestore
import com.stevesoltys.seedvault.transport.restore.OutputFactory
import io.mockk.Call
import io.mockk.MockKAnswerScope
import io.mockk.clearMocks
import io.mockk.coEvery
import io.mockk.every
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withContext
import kotlinx.coroutines.withTimeout
import org.calyxos.seedvault.core.toHexString
import org.koin.core.component.get
import java.security.DigestOutputStream
import java.security.MessageDigest
import kotlin.test.fail
internal interface LargeRestoreTestBase : LargeTestBase {
companion object {
private const val RESTORE_TIMEOUT = 360 * 1000L
}
val spyFullRestore: FullRestore get() = get()
val spyKVRestore: KVRestore get() = get()
val spyOutputFactory: OutputFactory get() = get()
fun launchRestoreActivity() {
runCommand("am start -n ${targetContext.packageName}/.restore.RestoreActivity")
waitUntilIdle()
}
fun typeInRestoreCode(code: List<String>) {
assert(code.size == 12) { "Code must have 12 words." }
RecoveryCodeScreen {
waitUntilIdle()
code.forEachIndexed { index, word ->
wordTextField(index).text = word
}
waitUntilIdle()
verifyCodeButton.scrollTo().click()
}
}
fun performRestore(): SeedvaultLargeTestResult {
val result = SeedvaultLargeTestResult(
full = mutableMapOf(),
kv = mutableMapOf(),
userApps = emptyList(), // will update everything below this after restore
)
spyOnRestoreData(result)
RestoreScreen {
backupListItem.clickAndWaitForNewWindow()
waitUntilIdle()
waitForAppSelectionLoaded()
// just tap next in app selection
appsSelectedButton.clickAndWaitForNewWindow()
waitForInstallResult()
if (someAppsNotInstalledText.exists()) {
device.pressBack()
}
nextButton.clickAndWaitForNewWindow()
waitForRestoreDataResult()
if (someAppsNotRestoredText.exists()) {
device.pressBack()
}
finishButton.clickAndWaitForNewWindow()
skipButton.clickAndWaitForNewWindow()
waitUntilIdle()
}
return result.copy(
userApps = packageService.userApps,
)
}
private fun spyOnRestoreData(result: SeedvaultLargeTestResult) {
clearMocks(spyOutputFactory)
spyOnFullRestoreData(result)
spyOnKVRestoreData(result)
}
private fun waitForAppSelectionLoaded() = runBlocking {
withContext(Dispatchers.Main) {
withTimeout(RESTORE_TIMEOUT) {
while (spyRestoreViewModel.selectedApps.value?.apps?.isNotEmpty() != true) {
delay(100)
}
}
}
waitUntilIdle()
}
private fun waitForInstallResult() = runBlocking {
withContext(Dispatchers.Main) {
withTimeout(RESTORE_TIMEOUT) {
while (spyRestoreViewModel.installResult.value?.isFinished != true) {
delay(100)
}
}
val restoreResultValue = spyRestoreViewModel.installResult.value
?: error("Restore APKs timed out")
// TODO: Fix this, with current test an app or two breaks on install with AOSP image.
// Just need to update the test data to work with the AOSP image.
// assert(!restoreResultValue.hasFailed) { "Failed to install packages" }
}
waitUntilIdle()
}
private fun waitForRestoreDataResult() = runBlocking {
withContext(Dispatchers.Main) {
withTimeout(RESTORE_TIMEOUT) {
while (spyRestoreViewModel.restoreBackupResult.value == null) {
delay(100)
}
}
val restoreResultValue = spyRestoreViewModel.restoreBackupResult.value
?: error("Restore app data timed out")
assert(!restoreResultValue.hasError()) {
"Restore failed: ${restoreResultValue.errorMsg}"
}
waitUntilIdle()
}
}
private fun spyOnKVRestoreData(restoreResult: SeedvaultLargeTestResult) {
var packageName: String? = null
clearMocks(spyKVRestore)
fun initializeStateBlock(
packageInfoIndex: Int
): MockKAnswerScope<Unit, Unit>.(Call) -> Unit = {
packageName = arg<PackageInfo>(packageInfoIndex).packageName
restoreResult.kv[packageName!!] = mutableMapOf()
callOriginal()
}
coEvery {
spyKVRestore.initializeState(any(), any(), any(), any())
} answers initializeStateBlock(1)
coEvery {
spyKVRestore.initializeStateV1(any(), any(), any(), any())
} answers initializeStateBlock(2)
coEvery {
spyKVRestore.initializeStateV0(any(), any())
} answers initializeStateBlock(1)
every {
spyOutputFactory.getBackupDataOutput(any())
} answers {
val fd = firstArg<ParcelFileDescriptor>().fileDescriptor
BackupDataOutputIntercept(fd) { key, value ->
restoreResult.kv[packageName!!]!![key] = value.sha256()
}
}
}
private fun spyOnFullRestoreData(restoreResult: SeedvaultLargeTestResult) {
var packageName: String? = null
val messageDigest = MessageDigest.getInstance("SHA-256")
var digestOutputStream: DigestOutputStream? = null
clearMocks(spyFullRestore)
fun initializeStateBlock(
packageInfoIndex: Int
): MockKAnswerScope<Unit, Unit>.(Call) -> Unit = {
packageName?.let {
// sometimes finishRestore() doesn't get called, so get data from last package here
digestOutputStream?.messageDigest?.let { digest ->
restoreResult.full[packageName!!] = digest.digest().toHexString()
}
}
packageName = arg<PackageInfo>(packageInfoIndex).packageName
callOriginal()
}
coEvery {
spyFullRestore.initializeState(any(), any(), any())
} answers initializeStateBlock(1)
coEvery {
spyFullRestore.initializeStateV1(any(), any(), any())
} answers initializeStateBlock(2)
coEvery {
spyFullRestore.initializeStateV0(any(), any())
} answers initializeStateBlock(1)
every {
spyOutputFactory.getOutputStream(any())
} answers {
digestOutputStream = DigestOutputStream(callOriginal(), messageDigest)
digestOutputStream!!
}
every {
spyFullRestore.abortFullRestore()
} answers {
packageName = null
digestOutputStream?.messageDigest?.reset()
callOriginal()
}
every {
spyFullRestore.finishRestore()
} answers {
val digest = digestOutputStream?.messageDigest ?: fail("No digestOutputStream")
restoreResult.full[packageName!!] = digest.digest().toHexString()
packageName = null
digest.reset()
callOriginal()
}
}
}

View file

@ -0,0 +1,240 @@
/*
* SPDX-FileCopyrightText: 2023 The Calyx Institute
* SPDX-License-Identifier: Apache-2.0
*/
package com.stevesoltys.seedvault.e2e
import android.app.UiAutomation
import android.app.backup.IBackupManager
import android.content.Context
import android.content.pm.PackageInfo
import android.content.pm.PackageManager.PERMISSION_GRANTED
import android.os.Environment
import androidx.annotation.WorkerThread
import androidx.preference.PreferenceManager
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.uiautomator.UiDevice
import androidx.test.uiautomator.Until
import com.stevesoltys.seedvault.crypto.ANDROID_KEY_STORE
import com.stevesoltys.seedvault.crypto.KEY_ALIAS_BACKUP
import com.stevesoltys.seedvault.crypto.KEY_ALIAS_MAIN
import com.stevesoltys.seedvault.crypto.KeyManager
import com.stevesoltys.seedvault.currentRestoreStorageViewModel
import com.stevesoltys.seedvault.currentRestoreViewModel
import com.stevesoltys.seedvault.e2e.screen.impl.BackupScreen
import com.stevesoltys.seedvault.e2e.screen.impl.DocumentPickerScreen
import com.stevesoltys.seedvault.e2e.screen.impl.RecoveryCodeScreen
import com.stevesoltys.seedvault.metadata.MetadataManager
import com.stevesoltys.seedvault.permitDiskReads
import com.stevesoltys.seedvault.restore.RestoreViewModel
import com.stevesoltys.seedvault.settings.SettingsManager
import com.stevesoltys.seedvault.transport.backup.PackageService
import com.stevesoltys.seedvault.ui.storage.RestoreStorageViewModel
import kotlinx.coroutines.DelicateCoroutinesApi
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import org.koin.core.component.KoinComponent
import org.koin.core.component.get
import java.io.File
import java.lang.Thread.sleep
import java.security.KeyStore
import java.security.MessageDigest
import java.text.SimpleDateFormat
import java.util.Calendar
import java.util.concurrent.atomic.AtomicBoolean
internal interface LargeTestBase : KoinComponent {
companion object {
private const val TEST_STORAGE_FOLDER = "seedvault_test"
private const val TEST_RESULT_FOLDER = "seedvault_test_results"
}
val externalStorageDir: String get() = Environment.getExternalStorageDirectory().absolutePath
val testStoragePath get() = "$externalStorageDir/$TEST_STORAGE_FOLDER"
val testResultPath get() = "$externalStorageDir/$TEST_RESULT_FOLDER"
val targetContext: Context
get() = InstrumentationRegistry.getInstrumentation().targetContext
val uiAutomation: UiAutomation
get() = InstrumentationRegistry.getInstrumentation().uiAutomation
val device: UiDevice
get() = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
val packageService: PackageService get() = get()
val settingsManager: SettingsManager get() = get()
val keyManager: KeyManager get() = get()
val spyMetadataManager: MetadataManager get() = get()
val backupManager: IBackupManager get() = get()
val spyRestoreViewModel: RestoreViewModel
get() = currentRestoreViewModel ?: error("currentRestoreViewModel is null")
val spyRestoreStorageViewModel: RestoreStorageViewModel
get() = currentRestoreStorageViewModel ?: error("currentRestoreStorageViewModel is null")
fun resetApplicationState() {
backupManager.setAutoRestore(false)
val sharedPreferences = permitDiskReads {
PreferenceManager.getDefaultSharedPreferences(targetContext)
}
sharedPreferences.edit().clear().apply()
KeyStore.getInstance(ANDROID_KEY_STORE).apply {
load(null)
}.apply {
deleteEntry(KEY_ALIAS_MAIN)
deleteEntry(KEY_ALIAS_BACKUP)
}
clearDocumentPickerAppData()
device.executeShellCommand("rm -R $externalStorageDir/.SeedVaultAndroidBackup")
}
fun waitUntilIdle() {
device.waitForIdle()
sleep(3000)
}
fun runCommand(command: String) {
uiAutomation.executeShellCommand(command).close()
}
fun testResultFilename(testName: String): String {
val simpleDateFormat = SimpleDateFormat("yyyyMMdd_hhmmss")
val timeStamp = simpleDateFormat.format(Calendar.getInstance().time)
return "${timeStamp}_${testName.replace(" ", "_")}"
}
@OptIn(DelicateCoroutinesApi::class)
@WorkerThread
suspend fun startRecordingTest(
keepRecordingScreen: AtomicBoolean,
testName: String,
) {
val folder = testResultPath
runCommand("mkdir -p $folder")
val fileName = testResultFilename(testName)
// screen record automatically stops after 3 minutes
// we need to block on a loop and split it into multiple files
GlobalScope.launch(Dispatchers.IO) {
var index = 0
while (keepRecordingScreen.get()) {
device.executeShellCommand("screenrecord $folder/$fileName-${index++}.mp4")
}
}
}
@WorkerThread
fun stopRecordingTest(
keepRecordingScreen: AtomicBoolean,
testName: String,
) {
keepRecordingScreen.set(false)
runCommand("pkill -2 screenrecord")
// write logcat to file
val fileName = testResultFilename(testName)
runCommand("logcat -d -f $testResultPath/$fileName.log")
}
fun uninstallPackages(packages: Collection<PackageInfo>) {
packages.forEach { runCommand("pm uninstall ${it.packageName}") }
}
fun clearDocumentPickerAppData() {
runCommand("pm clear com.google.android.documentsui")
}
fun clearTestBackups() {
File(testStoragePath).deleteRecursively()
File(testResultPath).deleteRecursively()
}
fun changeBackupLocation(
folderName: String = TEST_STORAGE_FOLDER,
exists: Boolean = false,
) {
BackupScreen {
clearDocumentPickerAppData()
backupLocationButton.clickAndWaitForNewWindow()
chooseStorageLocation(folderName, exists)
}
}
fun chooseStorageLocation(
folderName: String = TEST_STORAGE_FOLDER,
exists: Boolean = false,
) {
val manageDocumentsPermission =
targetContext.checkSelfPermission("android.permission.MANAGE_DOCUMENTS")
if (manageDocumentsPermission != PERMISSION_GRANTED) {
DocumentPickerScreen {
if (exists) {
existingFolder(folderName).scrollTo().clickAndWaitForNewWindow()
} else {
createNewFolderButton.clickAndWaitForNewWindow()
textBox.text = folderName
okButton.clickAndWaitForNewWindow()
}
useThisFolderButton.clickAndWaitForNewWindow()
allowButton.clickAndWaitForNewWindow()
}
} else {
val extDir = externalStorageDir
device.executeShellCommand("rm -R $extDir/.SeedVaultAndroidBackup")
device.executeShellCommand(
"cp -R $extDir/$folderName/" +
".SeedVaultAndroidBackup $extDir"
)
device.executeShellCommand("cp -R $extDir/$folderName/recovery-code.txt $extDir")
BackupScreen {
internalStorageButton.clickAndWaitForNewWindow()
if (useAnywayButton.waitForExists(3000)) {
useAnywayButton.clickAndWaitForNewWindow()
}
}
}
BackupScreen {
device.wait(Until.hasObject(initializingText), 10000)
device.wait(Until.gone(initializingText), 120000)
}
}
fun confirmCode() {
RecoveryCodeScreen {
startNewBackupButton.click()
confirmCodeButton.click()
verifyCodeButton.scrollTo().click()
}
}
fun ByteArray.sha256(): String {
val data = MessageDigest.getInstance("SHA-256").digest(this)
return data.joinToString("") { "%02x".format(it) }
}
}

View file

@ -0,0 +1,104 @@
/*
* SPDX-FileCopyrightText: 2023 The Calyx Institute
* SPDX-License-Identifier: Apache-2.0
*/
package com.stevesoltys.seedvault.e2e
import android.content.pm.PackageManager
import androidx.test.ext.junit.runners.AndroidJUnit4
import kotlinx.coroutines.runBlocking
import org.junit.After
import org.junit.Before
import org.junit.Rule
import org.junit.rules.TestName
import org.junit.runner.RunWith
import org.koin.core.component.KoinComponent
import java.io.File
import java.lang.Thread.sleep
import java.util.concurrent.atomic.AtomicBoolean
@RunWith(AndroidJUnit4::class)
internal abstract class SeedvaultLargeTest :
LargeBackupTestBase, LargeRestoreTestBase, KoinComponent {
@JvmField
@Rule
var name = TestName()
companion object {
private const val BASELINE_BACKUP_FOLDER = "seedvault_baseline"
private const val RECOVERY_CODE_FILE = "recovery-code.txt"
}
private val baselineBackupFolderPath get() = "$externalStorageDir/$BASELINE_BACKUP_FOLDER"
private val baselineBackupPath get() = "$baselineBackupFolderPath/.SeedVaultAndroidBackup"
private val baselineRecoveryCodePath = "$baselineBackupFolderPath/$RECOVERY_CODE_FILE"
private val keepRecordingScreen = AtomicBoolean(true)
@Before
open fun setUp() = runBlocking {
resetApplicationState()
clearTestBackups()
runCommand("bmgr enable true")
runCommand("bmgr transport com.stevesoltys.seedvault.transport.ConfigurableBackupTransport")
sleep(5000)
startRecordingTest(keepRecordingScreen, name.methodName)
restoreBaselineBackup()
}
@After
open fun tearDown() {
stopRecordingTest(keepRecordingScreen, name.methodName)
}
/**
* Restore the baseline backup, if it exists.
*
* This is a hand-crafted backup containing various apps and app data that we use for
* provisioning tests: https://github.com/seedvault-app/seedvault-test-data
*/
private fun restoreBaselineBackup() {
val backupFile = File(baselineBackupPath)
val manageDocumentsPermission =
targetContext.checkSelfPermission("android.permission.MANAGE_DOCUMENTS")
if (manageDocumentsPermission == PackageManager.PERMISSION_GRANTED) {
val extDir = externalStorageDir
device.executeShellCommand("rm -R $extDir/.SeedVaultAndroidBackup")
device.executeShellCommand(
"cp -R $extDir/$BASELINE_BACKUP_FOLDER/" +
".SeedVaultAndroidBackup $extDir"
)
device.executeShellCommand(
"cp -R $extDir/$BASELINE_BACKUP_FOLDER/" +
"recovery-code.txt $extDir"
)
}
if (backupFile.exists()) {
launchRestoreActivity()
chooseStorageLocation(folderName = BASELINE_BACKUP_FOLDER, exists = true)
typeInRestoreCode(baselineBackupRecoveryCode())
performRestore()
resetApplicationState()
}
}
private fun baselineBackupRecoveryCode(): List<String> {
val recoveryCodeFile = File(baselineRecoveryCodePath)
return recoveryCodeFile.readLines()
.filter { it.isNotBlank() }
.joinToString(separator = " ") { it.trim() }
.split(" ")
}
}

View file

@ -0,0 +1,29 @@
/*
* SPDX-FileCopyrightText: 2023 The Calyx Institute
* SPDX-License-Identifier: Apache-2.0
*/
package com.stevesoltys.seedvault.e2e
import android.content.pm.PackageInfo
import com.stevesoltys.seedvault.metadata.PackageMetadata
import com.stevesoltys.seedvault.restore.AppRestoreResult
/**
* Contains maps of (package name -> SHA-256 hashes) of application data.
*
* During backups and restores, we intercept the package data and store the result here.
* We can use this to validate that the restored app data actually matches the backed up data.
*
* For full backups, the mapping is: Map<PackageName, SHA-256>
* For K/V backups, the mapping is: Map<PackageName, Map<Key, SHA-256>>
*/
internal data class SeedvaultLargeTestResult(
val backupResults: Map<String, PackageMetadata?> = emptyMap(),
val restoreResults: Map<String, AppRestoreResult?> = emptyMap(),
val full: MutableMap<String, String>,
val kv: MutableMap<String, MutableMap<String, String>>,
val userApps: List<PackageInfo>,
) {
fun allUserApps() = userApps
}

View file

@ -0,0 +1,176 @@
/*
* SPDX-FileCopyrightText: 2023 The Calyx Institute
* SPDX-License-Identifier: Apache-2.0
*/
package com.stevesoltys.seedvault.e2e.impl
import android.content.Intent.FLAG_ACTIVITY_NEW_TASK
import android.util.Log
import androidx.test.filters.LargeTest
import com.stevesoltys.seedvault.MAGIC_PACKAGE_MANAGER
import com.stevesoltys.seedvault.e2e.SeedvaultLargeTest
import com.stevesoltys.seedvault.e2e.SeedvaultLargeTestResult
import com.stevesoltys.seedvault.metadata.PackageState
import com.stevesoltys.seedvault.transport.backup.isStopped
import org.junit.Test
@LargeTest
internal class BackupRestoreTest : SeedvaultLargeTest() {
@Test
fun `backup and restore applications`() {
launchBackupActivity()
if (!keyManager.hasBackupKey()) {
confirmCode()
}
if (settingsManager.getSafProperties() == null) {
chooseStorageLocation()
} else {
changeBackupLocation()
}
launchStoppedApps()
launchBackupActivity()
val backupResult = performBackup()
assertValidBackupMetadata(backupResult)
uninstallPackages(backupResult.allUserApps())
launchRestoreActivity()
val restoreResult = performRestore()
assertValidResults(backupResult, restoreResult)
}
private fun assertValidBackupMetadata(backup: SeedvaultLargeTestResult) {
// Assert all user apps have metadata.
backup.allUserApps().forEach { app ->
assert(backup.backupResults.containsKey(app.packageName)) {
"Metadata for $app missing from backup."
}
}
// Assert all metadata has a valid state.
backup.backupResults.forEach { (pkg, metadata) ->
assert(metadata != null) { "Metadata for $pkg is null." }
assert(metadata!!.state != PackageState.UNKNOWN_ERROR) {
"Metadata for $pkg has an unknown state."
}
}
}
private fun launchStoppedApps() {
val packageManager = targetContext.packageManager
val notBackedUp = packageService.notBackedUpPackages
notBackedUp.forEach { packageInfo ->
val i = packageManager.getLaunchIntentForPackage(packageInfo.packageName)?.apply {
addFlags(FLAG_ACTIVITY_NEW_TASK)
}
Log.i("TEST", "Launching $i")
try {
targetContext.startActivity(i)
} catch (e: Exception) {
Log.e("TEST", "Could not launch activity for ${packageInfo.packageName}", e)
}
waitUntilIdle()
}
waitUntilIdle()
notBackedUp.forEach { packageInfo ->
val pi = packageManager.getPackageInfo(packageInfo.packageName, 0)
Log.e("TEST", "${packageInfo.packageName} isStopped: ${pi.isStopped()}")
}
}
private fun assertValidResults(
backup: SeedvaultLargeTestResult,
restore: SeedvaultLargeTestResult,
) {
assertAllUserAppsWereRestored(backup, restore)
assertValidFullData(backup, restore)
assertValidKeyValueData(backup, restore)
}
private fun assertAllUserAppsWereRestored(
backup: SeedvaultLargeTestResult,
restore: SeedvaultLargeTestResult,
) {
val backupUserApps = backup.allUserApps()
.map { it.packageName }.toSet()
val restoreUserApps = restore.allUserApps()
.map { it.packageName }.toSet()
// Assert we re-installed all user apps.
assert(restoreUserApps.containsAll(backupUserApps)) {
val missingApps = backupUserApps
.minus(restoreUserApps)
.joinToString(", ")
"Not all user apps were restored. Missing: $missingApps"
}
// Assert we restored data for all user apps that had successful backups.
// This is expected to succeed because we are uninstalling the apps before restoring.
val missingFromRestore = backup.userApps
.map { it.packageName }
.filter { backup.backupResults[it]?.state == PackageState.APK_AND_DATA }
.filter { !restore.kv.containsKey(it) && !restore.full.containsKey(it) }
if (missingFromRestore.isNotEmpty()) {
val failedApps = missingFromRestore.joinToString(", ")
error("Not all user apps had their data restored. Missing: $failedApps")
}
}
private fun assertValidFullData(
backup: SeedvaultLargeTestResult,
restore: SeedvaultLargeTestResult,
) {
// Assert all "full" restored data matches the backup data.
val allUserPkgs = backup.allUserApps().map { it.packageName }
restore.full.forEach { (pkg, fullData) ->
if (allUserPkgs.contains(pkg)) {
assert(backup.full.containsKey(pkg)) {
"Full data for $pkg missing from restore."
}
if (backup.backupResults[pkg]!!.state == PackageState.APK_AND_DATA) {
assert(fullData == backup.full[pkg]!!) {
"Full data for $pkg does not match."
}
}
}
}
}
private fun assertValidKeyValueData(
backup: SeedvaultLargeTestResult,
restore: SeedvaultLargeTestResult,
) {
// Assert all "key/value" restored data matches the backup data.
restore.kv.forEach { (pkg, kvData) ->
if (pkg != MAGIC_PACKAGE_MANAGER) {
assert(backup.kv.containsKey(pkg)) {
"KV data for $pkg missing from backup."
}
kvData.forEach { (key, value) ->
assert(backup.kv[pkg]!!.containsKey(key)) {
"KV data for $pkg/$key exists in restore but is missing from backup."
}
assert(value.contentEquals(backup.kv[pkg]!![key]!!)) {
"KV data for $pkg/$key does not match."
}
}
}
}
}
}

View file

@ -0,0 +1,29 @@
/*
* SPDX-FileCopyrightText: 2023 The Calyx Institute
* SPDX-License-Identifier: Apache-2.0
*/
package com.stevesoltys.seedvault.e2e.io
import android.app.backup.BackupDataInput
import java.io.FileDescriptor
class BackupDataInputIntercept(
fileDescriptor: FileDescriptor,
private val callback: (String, ByteArray) -> Unit,
) : BackupDataInput(fileDescriptor) {
var currentKey: String? = null
override fun getKey(): String? {
currentKey = super.getKey()
return currentKey
}
override fun readEntityData(data: ByteArray, offset: Int, size: Int): Int {
val result = super.readEntityData(data, offset, size)
callback(currentKey!!, data.copyOf(result))
return result
}
}

View file

@ -0,0 +1,28 @@
/*
* SPDX-FileCopyrightText: 2023 The Calyx Institute
* SPDX-License-Identifier: Apache-2.0
*/
package com.stevesoltys.seedvault.e2e.io
import android.app.backup.BackupDataOutput
import java.io.FileDescriptor
class BackupDataOutputIntercept(
fileDescriptor: FileDescriptor,
private val callback: (String, ByteArray) -> Unit,
) : BackupDataOutput(fileDescriptor) {
private var currentKey: String? = null
override fun writeEntityHeader(key: String, dataSize: Int): Int {
currentKey = key
return super.writeEntityHeader(key, dataSize)
}
override fun writeEntityData(data: ByteArray, size: Int): Int {
callback(currentKey!!, data.copyOf())
return super.writeEntityData(data, size)
}
}

View file

@ -0,0 +1,49 @@
/*
* SPDX-FileCopyrightText: 2023 The Calyx Institute
* SPDX-License-Identifier: Apache-2.0
*/
package com.stevesoltys.seedvault.e2e.screen
import android.widget.ScrollView
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.uiautomator.Configurator
import androidx.test.uiautomator.UiDevice
import androidx.test.uiautomator.UiObject
import androidx.test.uiautomator.UiScrollable
import androidx.test.uiautomator.UiSelector
import java.lang.Thread.sleep
abstract class UiDeviceScreen<T> {
companion object {
private const val SELECTOR_TIMEOUT = 180000L
}
operator fun invoke(function: T.() -> Unit) {
function.invoke(this as T)
}
fun UiObject.scrollTo(
scrollSelector: UiSelector = UiSelector().className(ScrollView::class.java),
): UiObject {
val uiScrollable = UiScrollable(scrollSelector)
uiScrollable.waitForExists(SELECTOR_TIMEOUT)
uiScrollable.scrollIntoView(this)
waitForExists(SELECTOR_TIMEOUT)
sleep(2000)
return this
}
fun findObject(
block: UiSelector.() -> UiSelector,
): UiObject = device().findObject(
UiSelector().let { it.block() }
)
private fun device() = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
.also {
Configurator.getInstance().waitForSelectorTimeout = SELECTOR_TIMEOUT
}
}

View file

@ -0,0 +1,30 @@
/*
* SPDX-FileCopyrightText: 2023 The Calyx Institute
* SPDX-License-Identifier: Apache-2.0
*/
package com.stevesoltys.seedvault.e2e.screen.impl
import android.os.Build
import androidx.test.uiautomator.By
import androidx.test.uiautomator.BySelector
import com.stevesoltys.seedvault.e2e.screen.UiDeviceScreen
object BackupScreen : UiDeviceScreen<BackupScreen>() {
val backupMenu = findObject { description("More options") }
val backupNowButton = findObject { text("Backup now") }
val backupStatusButton = findObject { text("Backup status") }
val backupLocationButton = findObject { text("Backup location") }
val backupSwitch = findObject { text("Backup my apps") }
val internalStorageButton = findObject { textContains(Build.MODEL) }
val useAnywayButton = findObject { text("Use anyway") }
val initializingText: BySelector = By.textContains("Initializing backup location")
}

View file

@ -0,0 +1,24 @@
/*
* SPDX-FileCopyrightText: 2023 The Calyx Institute
* SPDX-License-Identifier: Apache-2.0
*/
package com.stevesoltys.seedvault.e2e.screen.impl
import android.widget.EditText
import com.stevesoltys.seedvault.e2e.screen.UiDeviceScreen
object DocumentPickerScreen : UiDeviceScreen<DocumentPickerScreen>() {
val createNewFolderButton = findObject { text("CREATE NEW FOLDER") }
val useThisFolderButton = findObject { text("USE THIS FOLDER") }
val textBox = findObject { className(EditText::class.java) }
val okButton = findObject { text("OK") }
val allowButton = findObject { text("ALLOW") }
fun existingFolder(folderName: String) = findObject { text(folderName) }
}

View file

@ -0,0 +1,19 @@
/*
* SPDX-FileCopyrightText: 2023 The Calyx Institute
* SPDX-License-Identifier: Apache-2.0
*/
package com.stevesoltys.seedvault.e2e.screen.impl
import com.stevesoltys.seedvault.e2e.screen.UiDeviceScreen
object RecoveryCodeScreen : UiDeviceScreen<RecoveryCodeScreen>() {
val startNewBackupButton = findObject { text("Start new") }
val confirmCodeButton = findObject { text("Confirm code") }
val verifyCodeButton = findObject { text("Verify") }
fun wordTextField(index: Int) = findObject { text("Word ${index + 1}") }
}

View file

@ -0,0 +1,27 @@
/*
* SPDX-FileCopyrightText: 2023 The Calyx Institute
* SPDX-License-Identifier: Apache-2.0
*/
package com.stevesoltys.seedvault.e2e.screen.impl
import com.stevesoltys.seedvault.e2e.screen.UiDeviceScreen
object RestoreScreen : UiDeviceScreen<RestoreScreen>() {
val backupListItem = findObject {
textContains("Android SDK") // device name of test backups
}
val appsSelectedButton = findObject { text("Restore backup") }
val nextButton = findObject { text("Next") }
val finishButton = findObject { text("Finish") }
val skipButton = findObject { text("Skip restoring files") }
val someAppsNotInstalledText = findObject { textContains("Some apps") }
val someAppsNotRestoredText = findObject { textContains("some apps") }
}

View file

@ -1,216 +0,0 @@
package com.stevesoltys.seedvault.plugins.saf
import android.database.ContentObserver
import android.database.Cursor
import android.net.Uri
import android.os.Bundle
import android.provider.DocumentsContract.EXTRA_LOADING
import androidx.documentfile.provider.DocumentFile
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import com.stevesoltys.seedvault.assertReadEquals
import com.stevesoltys.seedvault.coAssertThrows
import com.stevesoltys.seedvault.getRandomBase64
import com.stevesoltys.seedvault.getRandomByteArray
import com.stevesoltys.seedvault.settings.SettingsManager
import com.stevesoltys.seedvault.writeAndClose
import io.mockk.Runs
import io.mockk.every
import io.mockk.just
import io.mockk.mockk
import io.mockk.slot
import io.mockk.verify
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.TimeoutCancellationException
import kotlinx.coroutines.runBlocking
import org.junit.After
import org.junit.Assert.assertArrayEquals
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertTrue
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.koin.core.KoinComponent
import org.koin.core.inject
import java.io.IOException
import kotlin.random.Random
@RunWith(AndroidJUnit4::class)
@Suppress("BlockingMethodInNonBlockingContext")
class DocumentsStorageTest : KoinComponent {
private val context = InstrumentationRegistry.getInstrumentation().targetContext
private val settingsManager by inject<SettingsManager>()
private val storage = DocumentsStorage(context, settingsManager)
private val filename = getRandomBase64()
private lateinit var file: DocumentFile
@Before
fun setup() = runBlocking {
assertNotNull("Select a storage location in the app first!", storage.rootBackupDir)
file = storage.rootBackupDir?.createOrGetFile(context, filename)
?: error("Could not create test file")
}
@After
fun tearDown() {
file.delete()
}
@Test
fun testWritingAndReadingFile() {
// write to output stream
val outputStream = storage.getOutputStream(file)
val content = ByteArray(1337).apply { Random.nextBytes(this) }
outputStream.write(content)
outputStream.flush()
outputStream.close()
// read written data from input stream
val inputStream = storage.getInputStream(file)
val readContent = inputStream.readBytes()
inputStream.close()
assertArrayEquals(content, readContent)
// write smaller content to same file
val outputStream2 = storage.getOutputStream(file)
val content2 = ByteArray(42).apply { Random.nextBytes(this) }
outputStream2.write(content2)
outputStream2.flush()
outputStream2.close()
// read written data from input stream
val inputStream2 = storage.getInputStream(file)
val readContent2 = inputStream2.readBytes()
inputStream2.close()
assertArrayEquals(content2, readContent2)
}
@Test
fun testFindFile() = runBlocking(Dispatchers.IO) {
val foundFile = storage.rootBackupDir!!.findFileBlocking(context, file.name!!)
assertNotNull(foundFile)
assertEquals(filename, foundFile!!.name)
assertEquals(storage.rootBackupDir!!.uri, foundFile.parentFile?.uri)
}
@Test
fun testCreateFile() {
// create test file
val dir = storage.rootBackupDir!!
val createdFile = dir.createFile("text", getRandomBase64())
assertNotNull(createdFile)
assertNotNull(createdFile!!.name)
// write some data into it
val data = getRandomByteArray()
context.contentResolver.openOutputStream(createdFile.uri)!!.writeAndClose(data)
// data should still be there
assertReadEquals(data, context.contentResolver.openInputStream(createdFile.uri))
// delete again
createdFile.delete()
assertFalse(createdFile.exists())
}
@Test
fun testCreateTwoFiles() = runBlocking {
val mimeType = "application/octet-stream"
val dir = storage.rootBackupDir!!
// create test file
val name1 = getRandomBase64(Random.nextInt(1, 10))
val file1 = requireNotNull(dir.createFile(mimeType, name1))
assertTrue(file1.exists())
assertEquals(name1, file1.name)
assertEquals(0L, file1.length())
assertReadEquals(getRandomByteArray(0), context.contentResolver.openInputStream(file1.uri))
// write some data into it
val data1 = getRandomByteArray(5 * 1024 * 1024)
context.contentResolver.openOutputStream(file1.uri)!!.writeAndClose(data1)
assertEquals(data1.size.toLong(), file1.length())
// data should still be there
assertReadEquals(data1, context.contentResolver.openInputStream(file1.uri))
// create test file
val name2 = getRandomBase64(Random.nextInt(1, 10))
val file2 = requireNotNull(dir.createFile(mimeType, name2))
assertTrue(file2.exists())
assertEquals(name2, file2.name)
// write some data into it
val data2 = getRandomByteArray(12 * 1024 * 1024)
context.contentResolver.openOutputStream(file2.uri)!!.writeAndClose(data2)
assertEquals(data2.size.toLong(), file2.length())
// data should still be there
assertReadEquals(data2, context.contentResolver.openInputStream(file2.uri))
// delete files again
file1.delete()
file2.delete()
assertFalse(file1.exists())
assertFalse(file2.exists())
}
@Test
fun testGetLoadedCursor() = runBlocking {
// empty cursor extras are like not loading, returns same cursor right away
val cursor1: Cursor = mockk()
every { cursor1.extras } returns Bundle()
assertEquals(cursor1, getLoadedCursor { cursor1 })
// explicitly not loading, returns same cursor right away
val cursor2: Cursor = mockk()
every { cursor2.extras } returns Bundle().apply { putBoolean(EXTRA_LOADING, false) }
assertEquals(cursor2, getLoadedCursor { cursor2 })
// loading cursor registers content observer, times out and closes cursor
val cursor3: Cursor = mockk()
every { cursor3.extras } returns Bundle().apply { putBoolean(EXTRA_LOADING, true) }
every { cursor3.registerContentObserver(any()) } just Runs
every { cursor3.close() } just Runs
coAssertThrows(TimeoutCancellationException::class.java) {
getLoadedCursor(1000) { cursor3 }
}
verify { cursor3.registerContentObserver(any()) }
verify { cursor3.close() } // ensure that cursor gets closed
// loading cursor registers content observer, but re-query fails
val cursor4: Cursor = mockk()
val observer4 = slot<ContentObserver>()
val query: () -> Cursor? = { if (observer4.isCaptured) null else cursor4 }
every { cursor4.extras } returns Bundle().apply { putBoolean(EXTRA_LOADING, true) }
every { cursor4.registerContentObserver(capture(observer4)) } answers {
observer4.captured.onChange(false, Uri.parse("foo://bar"))
}
every { cursor4.close() } just Runs
coAssertThrows(IOException::class.java) {
getLoadedCursor(10_000, query)
}
assertTrue(observer4.isCaptured)
verify { cursor4.close() } // ensure that cursor gets closed
// loading cursor registers content observer, re-queries and returns new result
val cursor5: Cursor = mockk()
val result5: Cursor = mockk()
val observer5 = slot<ContentObserver>()
val query5: () -> Cursor? = { if (observer5.isCaptured) result5 else cursor5 }
every { cursor5.extras } returns Bundle().apply { putBoolean(EXTRA_LOADING, true) }
every { cursor5.registerContentObserver(capture(observer5)) } answers {
observer5.captured.onChange(false, null)
}
every { cursor5.close() } just Runs
assertEquals(result5, getLoadedCursor(10_000, query5))
assertTrue(observer5.isCaptured)
verify { cursor5.close() } // ensure that initial cursor got closed
}
}

View file

@ -0,0 +1,90 @@
/*
* SPDX-FileCopyrightText: 2024 The Calyx Institute
* SPDX-License-Identifier: Apache-2.0
*/
package com.stevesoltys.seedvault.transport.backup
import android.app.backup.BackupDataInput
import android.app.backup.BackupTransport.FLAG_NON_INCREMENTAL
import android.content.pm.PackageInfo
import android.os.ParcelFileDescriptor
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.MediumTest
import com.stevesoltys.seedvault.repo.BackupData
import com.stevesoltys.seedvault.repo.BackupReceiver
import io.mockk.CapturingSlot
import io.mockk.Runs
import io.mockk.coEvery
import io.mockk.every
import io.mockk.just
import io.mockk.mockk
import kotlinx.coroutines.runBlocking
import org.junit.Assert.assertArrayEquals
import org.junit.Assert.assertNull
import org.junit.Test
import org.junit.runner.RunWith
import org.koin.core.component.KoinComponent
import org.koin.core.component.inject
import kotlin.random.Random
import kotlin.test.assertEquals
@RunWith(AndroidJUnit4::class)
@MediumTest
class KvBackupInstrumentationTest : KoinComponent {
private val backupReceiver: BackupReceiver = mockk()
private val inputFactory: InputFactory = mockk()
private val dbManager: KvDbManager by inject()
private val backup = KVBackup(
backupReceiver = backupReceiver,
inputFactory = inputFactory,
dbManager = dbManager,
)
private val data = mockk<ParcelFileDescriptor>()
private val dataInput = mockk<BackupDataInput>()
private val key = "foo.bar"
private val dataValue = Random.nextBytes(23)
@Test
fun `test non-incremental backup with existing DB`() {
val packageName = "com.example"
val backupData = BackupData(emptyList(), emptyMap())
// create existing db
dbManager.getDb(packageName).use { db ->
db.put("foo", "bar".toByteArray())
}
val packageInfo = PackageInfo().apply {
this.packageName = packageName
}
every { inputFactory.getBackupDataInput(data) } returns dataInput
every { dataInput.readNextHeader() } returnsMany listOf(true, false)
every { dataInput.key } returns key
every { dataInput.dataSize } returns dataValue.size
val slot = CapturingSlot<ByteArray>()
every { dataInput.readEntityData(capture(slot), 0, dataValue.size) } answers {
dataValue.copyInto(slot.captured)
dataValue.size
}
every { data.close() } just Runs
backup.performBackup(packageInfo, data, FLAG_NON_INCREMENTAL)
coEvery { backupReceiver.readFromStream(any(), any()) } returns backupData
runBlocking {
assertEquals(backupData, backup.finishBackup())
}
dbManager.getDb(packageName).use { db ->
assertNull(db.get("foo")) // existing data foo is gone
assertArrayEquals(dataValue, db.get(key)) // new data got added
}
}
}

View file

@ -1,21 +1,70 @@
/*
* SPDX-FileCopyrightText: 2020 The Calyx Institute
* SPDX-License-Identifier: Apache-2.0
*/
package com.stevesoltys.seedvault.transport.backup
import android.content.pm.PackageInfo
import android.util.Log
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.MediumTest
import com.stevesoltys.seedvault.backend.BackendManager
import com.stevesoltys.seedvault.settings.AppStatus
import com.stevesoltys.seedvault.settings.SettingsManager
import io.mockk.every
import io.mockk.mockk
import org.calyxos.seedvault.core.backends.Backend
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Test
import org.junit.runner.RunWith
import org.koin.core.KoinComponent
import org.koin.core.inject
import org.koin.core.component.KoinComponent
import org.koin.core.component.inject
@RunWith(AndroidJUnit4::class)
@MediumTest
class PackageServiceTest : KoinComponent {
private val packageService: PackageService by inject()
private val settingsManager: SettingsManager by inject()
private val backendManager: BackendManager by inject()
private val backend: Backend get() = backendManager.backend
@Test
fun testNotAllowedPackages() {
val packages = packageService.notBackedUpPackages
Log.e("TEST", "Packages: $packages")
}
@Test
fun `shouldIncludeAppInBackup exempts plugin provider and blacklisted apps`() {
val packageInfo = PackageInfo().apply {
packageName = "com.example"
}
val disabledAppStatus = mockk<AppStatus>().apply {
every { packageName } returns packageInfo.packageName
every { enabled } returns false
}
settingsManager.onAppBackupStatusChanged(disabledAppStatus)
// Should not backup blacklisted apps
assertFalse(packageService.shouldIncludeAppInBackup(packageInfo.packageName))
val enabledAppStatus = mockk<AppStatus>().apply {
every { packageName } returns packageInfo.packageName
every { enabled } returns true
}
settingsManager.onAppBackupStatusChanged(enabledAppStatus)
// Should backup non-blacklisted apps
assertTrue(packageService.shouldIncludeAppInBackup(packageInfo.packageName))
// Should not backup storage provider
assertFalse(packageService.shouldIncludeAppInBackup(backend.providerPackageName!!))
}
}

View file

@ -0,0 +1,128 @@
/*
* SPDX-FileCopyrightText: 2024 The Calyx Institute
* SPDX-License-Identifier: Apache-2.0
*/
package com.stevesoltys.seedvault.worker
import android.content.pm.PackageInfo
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.MediumTest
import androidx.test.platform.app.InstrumentationRegistry
import com.github.luben.zstd.ZstdOutputStream
import com.google.protobuf.ByteString
import com.stevesoltys.seedvault.MAGIC_PACKAGE_MANAGER
import com.stevesoltys.seedvault.metadata.BackupType
import com.stevesoltys.seedvault.proto.SnapshotKt.blob
import com.stevesoltys.seedvault.repo.AppBackupManager
import com.stevesoltys.seedvault.repo.BackupData
import com.stevesoltys.seedvault.repo.BackupReceiver
import com.stevesoltys.seedvault.repo.Loader
import com.stevesoltys.seedvault.repo.SnapshotCreatorFactory
import com.stevesoltys.seedvault.transport.backup.PackageService
import io.mockk.Runs
import io.mockk.coEvery
import io.mockk.every
import io.mockk.just
import io.mockk.mockk
import io.mockk.slot
import junit.framework.TestCase.assertTrue
import kotlinx.coroutines.runBlocking
import org.calyxos.seedvault.core.backends.AppBackupFileType
import org.calyxos.seedvault.core.toHexString
import org.junit.Assert.assertArrayEquals
import org.junit.Test
import org.junit.runner.RunWith
import org.koin.core.component.KoinComponent
import org.koin.core.component.inject
import java.io.ByteArrayInputStream
import java.io.ByteArrayOutputStream
import kotlin.random.Random
@RunWith(AndroidJUnit4::class)
@MediumTest
class IconManagerTest : KoinComponent {
private val context = InstrumentationRegistry.getInstrumentation().targetContext
private val packageService by inject<PackageService>()
private val backupReceiver = mockk<BackupReceiver>()
private val loader = mockk<Loader>()
private val appBackupManager = mockk<AppBackupManager>()
private val snapshotCreatorFactory by inject<SnapshotCreatorFactory>()
private val snapshotCreator = snapshotCreatorFactory.createSnapshotCreator()
private val iconManager = IconManager(
context = context,
packageService = packageService,
crypto = mockk(),
backupReceiver = backupReceiver,
loader = loader,
appBackupManager = appBackupManager,
)
init {
every { appBackupManager.snapshotCreator } returns snapshotCreator
}
@Test
fun `test upload and then download`(): Unit = runBlocking {
// prepare output data
val output = slot<ByteArray>()
val chunkId = Random.nextBytes(32).toHexString()
val chunkList = listOf(chunkId)
val blobId = Random.nextBytes(32).toHexString()
val blob = blob { id = ByteString.fromHex(blobId) }
// upload icons and capture plaintext bytes
coEvery { backupReceiver.addBytes(any(), capture(output)) } just Runs
coEvery {
backupReceiver.finalize(any())
} returns BackupData(chunkList, mapOf(chunkId to blob))
iconManager.uploadIcons()
assertTrue(output.captured.isNotEmpty())
// @pm@ is needed
val pmPackageInfo = PackageInfo().apply { packageName = MAGIC_PACKAGE_MANAGER }
val backupData = BackupData(emptyList(), emptyMap())
snapshotCreator.onPackageBackedUp(pmPackageInfo, BackupType.KV, backupData)
// get snapshot and assert it has icon chunks
val snapshot = snapshotCreator.finalizeSnapshot()
assertTrue(snapshot.iconChunkIdsCount > 0)
// prepare data for downloading icons
val repoId = Random.nextBytes(32).toHexString()
val inputStream = ByteArrayInputStream(output.captured)
coEvery { loader.loadFile(AppBackupFileType.Blob(repoId, blobId)) } returns inputStream
// download icons and ensure we had an icon for at least one app
val iconSet = iconManager.downloadIcons(repoId, snapshot)
assertTrue(iconSet.isNotEmpty())
}
@Test
fun `test upload produces deterministic output`(): Unit = runBlocking {
val output1 = slot<ByteArray>()
val output2 = slot<ByteArray>()
coEvery { backupReceiver.addBytes(any(), capture(output1)) } just Runs
coEvery { backupReceiver.finalize(any()) } returns BackupData(emptyList(), emptyMap())
iconManager.uploadIcons()
assertTrue(output1.captured.isNotEmpty())
coEvery { backupReceiver.addBytes(any(), capture(output2)) } just Runs
coEvery { backupReceiver.finalize(any()) } returns BackupData(emptyList(), emptyMap())
iconManager.uploadIcons()
assertTrue(output2.captured.isNotEmpty())
assertArrayEquals(output1.captured, output2.captured)
// print compressed and uncompressed size
val size = output1.captured.size.toFloat() / 1024 / 1024
val outputStream = ByteArrayOutputStream()
ZstdOutputStream(outputStream).use { it.write(output1.captured) }
val compressedSize = outputStream.size().toFloat() / 1024 / 1024
println("Icon size: $size MB, compressed $compressedSize MB")
}
}

View file

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
SPDX-FileCopyrightText: 2020 The Calyx Institute
SPDX-License-Identifier: Apache-2.0
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<application>
<!-- Remove permission requirements only for debug versions to make development easier -->
<activity
android:name="com.stevesoltys.seedvault.settings.SettingsActivity"
android:exported="true"
tools:remove="android:permission">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.stevesoltys.seedvault.restore.RestoreActivity"
android:exported="true"
tools:remove="android:permission" />
</application>
</manifest>

View file

@ -1,10 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
SPDX-FileCopyrightText: 2020 The Calyx Institute
SPDX-License-Identifier: Apache-2.0
-->
<resources>
<bool name="show_restore_in_settings">true</bool>
<string-array name="storage_authority_whitelist">
<item>com.android.externalstorage.documents</item>
<item>org.nextcloud.documents</item>
<item>org.nextcloud.beta.documents</item>
<item>at.bitfire.davdroid.webdav</item>
<item>de.felixnuesse.extract.vcp</item>
</string-array>
</resources>

View file

@ -1,9 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
SPDX-FileCopyrightText: 2017-2019 Steve Soltys
SPDX-FileCopyrightText: 2020 The Calyx Institute
SPDX-License-Identifier: Apache-2.0
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.stevesoltys.seedvault"
android:versionCode="30000221"
android:versionName="11-2.2">
android:versionCode="35050000"
android:versionName="15-5.0">
<!--
The version code is the targeted SDK_VERSION plus 6 digits for our own version code.
The version name is the targeted Android version followed by - and our own version name.
@ -16,7 +21,14 @@
<!-- This is needed to check for internet access when backup is stored on network storage -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<!-- This is needed to retrieve the available storage roots -->
<!-- Used for internal WebDAV plugin -->
<uses-permission android:name="android.permission.INTERNET" />
<!-- This is needed to inform users about backup status and errors -->
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<!-- (Optional) This is needed to retrieve the available storage roots.
The user needs to manually select a storage root, if not granted. -->
<uses-permission
android:name="android.permission.MANAGE_DOCUMENTS"
tools:ignore="ProtectedPermissions" />
@ -50,6 +62,23 @@
<!-- Used to authenticate saving a new recovery code -->
<uses-permission android:name="android.permission.USE_BIOMETRIC" />
<!-- This is needed to query content providers in other users -->
<uses-permission
android:name="android.permission.INTERACT_ACROSS_USERS_FULL"
tools:ignore="ProtectedPermissions" />
<!-- Used to get logcat for system part of backup API, gets permission dialog -->
<uses-permission
android:name="android.permission.READ_LOGS"
tools:ignore="ProtectedPermissions" />
<!-- Used to get the name of the current profile -->
<uses-permission android:name="android.permission.QUERY_USERS"
tools:ignore="ProtectedPermissions" />
<!-- Used for periodic storage backups -->
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
<!-- Permission used to open settings -->
<permission
android:name="com.stevesoltys.seedvault.OPEN_SETTINGS"
@ -65,19 +94,20 @@
android:allowBackup="false"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:ignore="GoogleAppIndexingWarning">
<activity
android:name=".settings.SettingsActivity"
android:exported="true"
android:launchMode="singleTask"
android:permission="com.stevesoltys.seedvault.OPEN_SETTINGS"
android:exported="true" />
android:windowSoftInputMode="adjustResize" />
<activity
android:name=".ui.storage.StorageActivity"
android:theme="@style/AppTheme.NoActionBar" />
android:windowSoftInputMode="adjustResize" />
<activity
android:name=".ui.storage.PermissionGrantActivity"
@ -87,20 +117,25 @@
<activity
android:name=".ui.recoverycode.RecoveryCodeActivity"
android:label="@string/recovery_code_title"
android:theme="@style/AppTheme.NoActionBar" />
android:windowSoftInputMode="adjustResize" />
<activity
android:name=".restore.RestoreActivity"
android:permission="com.stevesoltys.seedvault.RESTORE_BACKUP"
android:exported="true"
android:label="@string/restore_title"
android:theme="@style/AppTheme.NoActionBar">
android:launchMode="singleTask"
android:permission="com.stevesoltys.seedvault.RESTORE_BACKUP">
<intent-filter>
<action android:name="com.stevesoltys.seedvault.RESTORE_BACKUP" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".ui.check.AppCheckResultActivity"
android:label="@string/notification_checking_finished_title"
android:launchMode="singleTask"/>
<service
android:name=".transport.ConfigurableBackupTransportService"
android:exported="false">
@ -128,28 +163,30 @@
</intent-filter>
</receiver>
<receiver
android:name=".SecretCodeReceiver">
<intent-filter>
<action android:name="android.telephony.action.SECRET_CODE" />
<!-- *#*#RESTORE#*#* -->
<data android:scheme="android_secret_code" android:host="7378673" />
</intent-filter>
</receiver>
<!-- Used by Workmanager to schedule our workers -->
<service
android:name="androidx.work.impl.foreground.SystemForegroundService"
android:foregroundServiceType="dataSync"
tools:node="merge" />
<!-- Used to start actual BackupService depending on scheduling criteria -->
<service
android:name=".storage.StorageBackupJobService"
android:exported="false"
android:label="BackupJobService"
android:permission="android.permission.BIND_JOB_SERVICE" />
<!-- Does the actual backup work as a foreground service -->
<!-- Does app restore as a foreground service -->
<service
android:name=".restore.RestoreService"
android:exported="false"
android:foregroundServiceType="dataSync"
android:label="RestoreService" />
<!-- Does the actual file backup work as a foreground service -->
<service
android:name=".storage.StorageBackupService"
android:exported="false"
android:foregroundServiceType="dataSync"
android:label="BackupService" />
<!-- Does restore as a foreground service -->
<!-- Does file restore as a foreground service -->
<service
android:name=".storage.StorageRestoreService"
android:exported="false"

View file

@ -0,0 +1,23 @@
<!--
SPDX-FileCopyrightText: 2024 The Calyx Institute
SPDX-License-Identifier: Apache-2.0
-->
<configuration
xmlns="https://tony19.github.io/logback-android/xml"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://tony19.github.io/logback-android/xml https://cdn.jsdelivr.net/gh/tony19/logback-android/logback.xsd"
>
<appender name="logcat" class="ch.qos.logback.classic.android.LogcatAppender">
<tagEncoder>
<pattern>%logger{12}</pattern>
</tagEncoder>
<encoder>
<pattern>[%-20thread] %msg</pattern>
</encoder>
</appender>
<root level="DEBUG">
<appender-ref ref="logcat" />
</root>
</configuration>

View file

@ -1,35 +1,58 @@
/*
* SPDX-FileCopyrightText: 2020 The Calyx Institute
* SPDX-License-Identifier: Apache-2.0
*/
package com.stevesoltys.seedvault
import android.Manifest.permission.INTERACT_ACROSS_USERS_FULL
import android.app.ActivityManager
import android.app.ActivityManager.RunningAppProcessInfo
import android.app.Application
import android.app.backup.BackupManager
import android.app.backup.BackupManager.PACKAGE_MANAGER_SENTINEL
import android.app.backup.IBackupManager
import android.content.Context.BACKUP_SERVICE
import android.content.Context
import android.content.pm.PackageManager.PERMISSION_GRANTED
import android.os.Build
import android.os.ServiceManager.getService
import android.os.StrictMode
import android.os.UserHandle
import android.os.UserManager
import android.util.Log
import androidx.work.ExistingPeriodicWorkPolicy.UPDATE
import androidx.work.WorkManager
import com.google.android.material.color.DynamicColors
import com.stevesoltys.seedvault.MemoryLogger.getMemStr
import com.stevesoltys.seedvault.backend.BackendManager
import com.stevesoltys.seedvault.backend.saf.storagePluginModuleSaf
import com.stevesoltys.seedvault.backend.webdav.storagePluginModuleWebDav
import com.stevesoltys.seedvault.crypto.cryptoModule
import com.stevesoltys.seedvault.header.headerModule
import com.stevesoltys.seedvault.metadata.MetadataManager
import com.stevesoltys.seedvault.metadata.metadataModule
import com.stevesoltys.seedvault.plugins.saf.documentsProviderModule
import com.stevesoltys.seedvault.restore.RestoreViewModel
import com.stevesoltys.seedvault.repo.repoModule
import com.stevesoltys.seedvault.restore.install.installModule
import com.stevesoltys.seedvault.restore.restoreUiModule
import com.stevesoltys.seedvault.settings.AppListRetriever
import com.stevesoltys.seedvault.settings.SettingsManager
import com.stevesoltys.seedvault.settings.SettingsViewModel
import com.stevesoltys.seedvault.storage.storageModule
import com.stevesoltys.seedvault.transport.TRANSPORT_ID
import com.stevesoltys.seedvault.transport.backup.backupModule
import com.stevesoltys.seedvault.transport.restore.restoreModule
import com.stevesoltys.seedvault.ui.files.FileSelectionViewModel
import com.stevesoltys.seedvault.ui.notification.BackupNotificationManager
import com.stevesoltys.seedvault.ui.recoverycode.RecoveryCodeViewModel
import com.stevesoltys.seedvault.ui.storage.BackupStorageViewModel
import com.stevesoltys.seedvault.ui.storage.RestoreStorageViewModel
import com.stevesoltys.seedvault.worker.AppBackupWorker
import com.stevesoltys.seedvault.worker.workerModule
import org.calyxos.seedvault.core.backends.BackendFactory
import org.koin.android.ext.android.inject
import org.koin.android.ext.koin.androidContext
import org.koin.android.ext.koin.androidLogger
import org.koin.androidx.viewmodel.dsl.viewModel
import org.koin.core.context.startKoin
import org.koin.core.logger.Level
import org.koin.dsl.module
/**
@ -38,24 +61,61 @@ import org.koin.dsl.module
*/
open class App : Application() {
open val isTest: Boolean = false
private val appModule = module {
single { SettingsManager(this@App) }
single { BackupNotificationManager(this@App) }
single { BackendManager(this@App, get(), get(), get()) }
single {
BackendFactory {
// uses context of the device's main user to be able to access USB storage
this@App.applicationContext.getStorageContext {
get<SettingsManager>().getSafProperties()?.isUsb == true
}
}
}
single { BackupStateManager(this@App) }
single { Clock() }
factory<IBackupManager> { IBackupManager.Stub.asInterface(getService(BACKUP_SERVICE)) }
factory { AppListRetriever(this@App, get(), get(), get()) }
viewModel { SettingsViewModel(this@App, get(), get(), get(), get(), get(), get()) }
viewModel { RecoveryCodeViewModel(this@App, get(), get(), get(), get(), get()) }
viewModel { BackupStorageViewModel(this@App, get(), get(), get(), get()) }
viewModel { RestoreStorageViewModel(this@App, get(), get()) }
viewModel { RestoreViewModel(this@App, get(), get(), get(), get(), get(), get()) }
viewModel { FileSelectionViewModel(this@App, get()) }
viewModel {
SettingsViewModel(
app = this@App,
settingsManager = get(),
keyManager = get(),
backendManager = get(),
appListRetriever = get(),
storageBackup = get(),
backupManager = get(),
backupStateManager = get(),
checker = get(),
)
}
viewModel {
RecoveryCodeViewModel(this@App, get(), get(), get(), get(), get(), get(), get())
}
viewModel {
BackupStorageViewModel(
app = this@App,
backupManager = get(),
backupInitializer = get(),
storageBackup = get(),
safHandler = get(),
webDavHandler = get(),
settingsManager = get(),
backendManager = get(),
)
}
viewModel { RestoreStorageViewModel(this@App, get(), get(), get(), get()) }
}
override fun onCreate() {
super.onCreate()
DynamicColors.applyToActivitiesIfAvailable(this)
startKoin()
if (!isTest) migrateToOwnScheduling()
if (isDebugBuild()) {
StrictMode.setThreadPolicy(
StrictMode.ThreadPolicy.Builder()
@ -71,51 +131,73 @@ open class App : Application() {
.build()
)
}
permitDiskReads {
migrateTokenFromMetadataToSettingsManager()
}
}
protected open fun startKoin() = startKoin {
androidLogger()
androidLogger(Level.ERROR)
androidContext(this@App)
modules(
listOf(
cryptoModule,
headerModule,
metadataModule,
documentsProviderModule, // storage plugin
backupModule,
restoreModule,
installModule,
storageModule,
appModule
)
)
modules(appModules())
}
open fun appModules() = listOf(
cryptoModule,
headerModule,
metadataModule,
storagePluginModuleSaf,
storagePluginModuleWebDav,
backupModule,
restoreModule,
installModule,
storageModule,
repoModule,
workerModule,
restoreUiModule,
appModule
)
private val settingsManager: SettingsManager by inject()
private val metadataManager: MetadataManager by inject()
private val backupManager: IBackupManager by inject()
private val backendManager: BackendManager by inject()
private val backupStateManager: BackupStateManager by inject()
override fun onTrimMemory(level: Int) {
Log.w("Seedvault", "onTrimMemory($level) ${getMemStr()}")
val processInfo = RunningAppProcessInfo()
ActivityManager.getMyMemoryState(processInfo)
Log.w("Seedvault", " lastTrimLevel: ${processInfo.lastTrimLevel}")
Log.w("Seedvault", " importance: ${processInfo.importance}")
super.onTrimMemory(level)
}
/**
* The responsibility for the current token was moved to the [SettingsManager]
* in the end of 2020.
* This method migrates the token for existing installs and can be removed
* after sufficient time has passed.
* Disables the framework scheduling in favor of our own.
* Introduced in the first half of 2024 and can be removed after a suitable migration period.
*/
private fun migrateTokenFromMetadataToSettingsManager() {
@Suppress("DEPRECATION")
val token = metadataManager.getBackupToken()
if (token != 0L && settingsManager.getToken() == null) {
settingsManager.setNewToken(token)
protected open fun migrateToOwnScheduling() {
if (!backupStateManager.isFrameworkSchedulingEnabled) { // already on own scheduling
// fix things for removable drive users who had a job scheduled here before
if (backendManager.isOnRemovableDrive) AppBackupWorker.unschedule(applicationContext)
return
}
if (backupManager.currentTransport == TRANSPORT_ID) {
backupManager.setFrameworkSchedulingEnabledForUser(UserHandle.myUserId(), false)
if (backupManager.isBackupEnabled && !backendManager.isOnRemovableDrive) {
AppBackupWorker.schedule(applicationContext, settingsManager, UPDATE)
}
// cancel old D2D worker
WorkManager.getInstance(this).cancelUniqueWork("APP_BACKUP")
}
}
}
const val MAGIC_PACKAGE_MANAGER = PACKAGE_MANAGER_SENTINEL
const val MAGIC_PACKAGE_MANAGER: String = PACKAGE_MANAGER_SENTINEL
const val ANCESTRAL_RECORD_KEY = "@ancestral_record@"
const val NO_DATA_END_SENTINEL = "@end@"
const val GLOBAL_METADATA_KEY = "@meta@"
const val ERROR_BACKUP_CANCELLED: Int = BackupManager.ERROR_BACKUP_CANCELLED
const val ERROR_BACKUP_NOT_ALLOWED: Int = BackupManager.ERROR_BACKUP_NOT_ALLOWED
// TODO this doesn't work for LineageOS as they do public debug builds
fun isDebugBuild() = Build.TYPE == "userdebug"
@ -137,3 +219,16 @@ fun <T> permitDiskReads(func: () -> T): T {
func()
}
}
/**
* Hack to allow other profiles access to USB backend.
* @return the context of the device's main user, so use with great care!
*/
@Suppress("MissingPermission")
fun Context.getStorageContext(isUsbStorage: () -> Boolean): Context {
if (checkSelfPermission(INTERACT_ACROSS_USERS_FULL) == PERMISSION_GRANTED && isUsbStorage()) {
UserManager.get(this).getProfileParent(user)
?.let { parent -> return createContextAsUser(parent, 0) }
}
return this
}

View file

@ -1,22 +1,38 @@
/*
* SPDX-FileCopyrightText: 2020 The Calyx Institute
* SPDX-License-Identifier: Apache-2.0
*/
package com.stevesoltys.seedvault
import android.app.backup.BackupManagerMonitor.EXTRA_LOG_EVENT_CATEGORY
import android.app.backup.BackupManagerMonitor.EXTRA_LOG_EVENT_ID
import android.app.backup.BackupManagerMonitor.EXTRA_LOG_EVENT_PACKAGE_NAME
import android.app.backup.BackupManagerMonitor.EXTRA_LOG_PREFLIGHT_ERROR
import android.app.backup.BackupManagerMonitor.LOG_EVENT_ID_ERROR_PREFLIGHT
import android.app.backup.IBackupManagerMonitor
import android.os.Bundle
import android.util.Log
import android.util.Log.DEBUG
private val TAG = BackupMonitor::class.java.name
class BackupMonitor : IBackupManagerMonitor.Stub() {
open class BackupMonitor : IBackupManagerMonitor.Stub() {
override fun onEvent(bundle: Bundle) {
if (!Log.isLoggable(TAG, DEBUG)) return
Log.d(TAG, "ID: " + bundle.getInt(EXTRA_LOG_EVENT_ID))
Log.d(TAG, "CATEGORY: " + bundle.getInt(EXTRA_LOG_EVENT_CATEGORY, -1))
Log.d(TAG, "PACKAGE: " + bundle.getString(EXTRA_LOG_EVENT_PACKAGE_NAME, "?"))
onEvent(
id = bundle.getInt(EXTRA_LOG_EVENT_ID),
category = bundle.getInt(EXTRA_LOG_EVENT_CATEGORY),
packageName = bundle.getString(EXTRA_LOG_EVENT_PACKAGE_NAME),
bundle = bundle,
)
}
open fun onEvent(id: Int, category: Int, packageName: String?, bundle: Bundle) {
Log.d(TAG, "${packageName?.padEnd(64, ' ')} cat: $category id: $id")
if (id == LOG_EVENT_ID_ERROR_PREFLIGHT) {
val preflightResult = bundle.getLong(EXTRA_LOG_PREFLIGHT_ERROR, -1)
Log.w(TAG, "Pre-flight error from $packageName: $preflightResult")
}
}
}

View file

@ -0,0 +1,66 @@
/*
* SPDX-FileCopyrightText: 2024 The Calyx Institute
* SPDX-License-Identifier: Apache-2.0
*/
package com.stevesoltys.seedvault
import android.content.Context
import android.provider.Settings
import android.provider.Settings.Secure.BACKUP_AUTO_RESTORE
import android.provider.Settings.Secure.BACKUP_SCHEDULING_ENABLED
import android.util.Log
import androidx.work.WorkInfo.State.RUNNING
import androidx.work.WorkManager
import com.stevesoltys.seedvault.storage.StorageBackupService
import com.stevesoltys.seedvault.transport.ConfigurableBackupTransportService
import com.stevesoltys.seedvault.worker.AppBackupPruneWorker
import com.stevesoltys.seedvault.worker.AppBackupWorker.Companion.UNIQUE_WORK_NAME
import com.stevesoltys.seedvault.worker.AppCheckerWorker
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.combine
private const val TAG = "BackupStateManager"
class BackupStateManager(
context: Context,
) {
private val workManager = WorkManager.getInstance(context)
private val contentResolver = context.contentResolver
val isBackupRunning: Flow<Boolean> = combine(
flow = ConfigurableBackupTransportService.isRunning,
flow2 = StorageBackupService.isRunning,
flow3 = workManager.getWorkInfosForUniqueWorkFlow(UNIQUE_WORK_NAME),
) { appBackupRunning, filesBackupRunning, workInfo1 ->
val workInfoState1 = workInfo1.getOrNull(0)?.state
Log.i(
TAG, "appBackupRunning: $appBackupRunning, " +
"filesBackupRunning: $filesBackupRunning, " +
"appBackupWorker: ${workInfoState1?.name}"
)
appBackupRunning || filesBackupRunning || workInfoState1 == RUNNING
}
val isCheckOrPruneRunning: Flow<Boolean> = combine(
flow = workManager.getWorkInfosForUniqueWorkFlow(AppBackupPruneWorker.UNIQUE_WORK_NAME),
flow2 = workManager.getWorkInfosForUniqueWorkFlow(AppCheckerWorker.UNIQUE_WORK_NAME),
) { pruneInfo, checkInfo ->
val pruneInfoState = pruneInfo.getOrNull(0)?.state
val checkInfoState = checkInfo.getOrNull(0)?.state
Log.i(
TAG,
"pruneBackupWorker: ${pruneInfoState?.name}, " +
"appCheckerWorker: ${checkInfoState?.name}"
)
pruneInfoState == RUNNING || checkInfoState == RUNNING
}
val isAutoRestoreEnabled: Boolean
get() = Settings.Secure.getInt(contentResolver, BACKUP_AUTO_RESTORE, 1) == 1
val isFrameworkSchedulingEnabled: Boolean
get() = Settings.Secure.getInt(contentResolver, BACKUP_SCHEDULING_ENABLED, 1) == 1
}

View file

@ -1,3 +1,8 @@
/*
* SPDX-FileCopyrightText: 2020 The Calyx Institute
* SPDX-License-Identifier: Apache-2.0
*/
package com.stevesoltys.seedvault
import java.nio.charset.Charset

View file

@ -1,3 +1,8 @@
/*
* SPDX-FileCopyrightText: 2020 The Calyx Institute
* SPDX-License-Identifier: Apache-2.0
*/
package com.stevesoltys.seedvault
/**

View file

@ -0,0 +1,24 @@
/*
* SPDX-FileCopyrightText: 2024 The Calyx Institute
* SPDX-License-Identifier: Apache-2.0
*/
package com.stevesoltys.seedvault
import android.util.Log
object MemoryLogger {
fun log() {
Log.d("MemoryLogger", getMemStr())
}
fun getMemStr(): String {
val r = Runtime.getRuntime()
val total = r.totalMemory() / 1024 / 1024
val free = r.freeMemory() / 1024 / 1024
val max = r.maxMemory() / 1024 / 1024
val used = total - free
return "$free MiB free - $used of $total (max $max)"
}
}

View file

@ -1,24 +0,0 @@
package com.stevesoltys.seedvault
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.content.Intent.FLAG_ACTIVITY_NEW_TASK
import android.util.Log
import com.stevesoltys.seedvault.restore.RestoreActivity
private val TAG = BroadcastReceiver::class.java.simpleName
private val RESTORE_SECRET_CODE = "7378673"
class SecretCodeReceiver : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
val host = intent.data.host
if (!RESTORE_SECRET_CODE.equals(host)) return
Log.d(TAG, "Restore secret code received.")
val i = Intent(context, RestoreActivity::class.java).apply {
flags = FLAG_ACTIVITY_NEW_TASK
}
context.startActivity(i)
}
}

View file

@ -1,5 +1,11 @@
/*
* SPDX-FileCopyrightText: 2020 The Calyx Institute
* SPDX-License-Identifier: Apache-2.0
*/
package com.stevesoltys.seedvault
import android.app.backup.IBackupManager
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
@ -14,26 +20,20 @@ import android.os.Handler
import android.os.Looper
import android.provider.DocumentsContract
import android.util.Log
import androidx.core.content.ContextCompat.startForegroundService
import com.stevesoltys.seedvault.metadata.MetadataManager
import com.stevesoltys.seedvault.settings.FlashDrive
import com.stevesoltys.seedvault.settings.SettingsManager
import com.stevesoltys.seedvault.storage.StorageBackupService
import com.stevesoltys.seedvault.storage.StorageBackupService.Companion.EXTRA_START_APP_BACKUP
import com.stevesoltys.seedvault.transport.requestBackup
import com.stevesoltys.seedvault.ui.storage.AUTHORITY_STORAGE
import org.koin.core.context.KoinContextHandler.get
import java.util.concurrent.TimeUnit.HOURS
import com.stevesoltys.seedvault.worker.BackupRequester.Companion.requestFilesAndAppBackup
import org.koin.core.context.GlobalContext.get
import java.util.Date
private val TAG = UsbIntentReceiver::class.java.simpleName
private const val HOURS_AUTO_BACKUP: Long = 24
class UsbIntentReceiver : UsbMonitor() {
// using KoinComponent would crash robolectric tests :(
private val settingsManager: SettingsManager by lazy { get().get<SettingsManager>() }
private val metadataManager: MetadataManager by lazy { get().get<MetadataManager>() }
private val settingsManager: SettingsManager by lazy { get().get() }
private val backupManager: IBackupManager by lazy { get().get() }
override fun shouldMonitorStatus(context: Context, action: String, device: UsbDevice): Boolean {
if (action != ACTION_USB_DEVICE_ATTACHED) return false
@ -42,12 +42,15 @@ class UsbIntentReceiver : UsbMonitor() {
val attachedFlashDrive = FlashDrive.from(device)
return if (savedFlashDrive == attachedFlashDrive) {
Log.d(TAG, "Matches stored device, checking backup time...")
val backupMillis = System.currentTimeMillis() - metadataManager.getLastBackupTime()
if (backupMillis >= HOURS.toMillis(HOURS_AUTO_BACKUP)) {
Log.d(TAG, "Last backup older than 24 hours, requesting a backup...")
val lastBackupTime = settingsManager.lastBackupTime.value ?: 0
val backupMillis = System.currentTimeMillis() - lastBackupTime
if (backupMillis >= settingsManager.backupFrequencyInMillis) {
Log.d(TAG, "Last backup older than it should be, requesting a backup...")
Log.d(TAG, " ${Date(lastBackupTime)}")
true
} else {
Log.d(TAG, "We have a recent backup, not requesting a new one.")
Log.d(TAG, " ${Date(lastBackupTime)}")
false
}
} else {
@ -57,16 +60,7 @@ class UsbIntentReceiver : UsbMonitor() {
}
override fun onStatusChanged(context: Context, action: String, device: UsbDevice) {
if (settingsManager.isStorageBackupEnabled()) {
val i = Intent(context, StorageBackupService::class.java)
// this starts an app backup afterwards
i.putExtra(EXTRA_START_APP_BACKUP, true)
startForegroundService(context, i)
} else {
Thread {
requestBackup(context)
}.start()
}
requestFilesAndAppBackup(context, settingsManager, backupManager)
}
}
@ -82,7 +76,7 @@ abstract class UsbMonitor : BroadcastReceiver() {
if (intent.action == ACTION_USB_DEVICE_ATTACHED ||
intent.action == ACTION_USB_DEVICE_DETACHED
) {
val device = intent.extras?.getParcelable<UsbDevice>(EXTRA_DEVICE) ?: return
val device = intent.extras?.getParcelable(EXTRA_DEVICE, UsbDevice::class.java) ?: return
Log.d(TAG, "New USB mass-storage device attached.")
device.log()

View file

@ -0,0 +1,144 @@
/*
* SPDX-FileCopyrightText: 2024 The Calyx Institute
* SPDX-License-Identifier: Apache-2.0
*/
package com.stevesoltys.seedvault.backend
import android.content.Context
import android.util.Log
import androidx.annotation.WorkerThread
import com.stevesoltys.seedvault.getStorageContext
import com.stevesoltys.seedvault.permitDiskReads
import com.stevesoltys.seedvault.repo.BlobCache
import com.stevesoltys.seedvault.settings.SettingsManager
import com.stevesoltys.seedvault.settings.StoragePluginType
import org.calyxos.seedvault.core.backends.Backend
import org.calyxos.seedvault.core.backends.BackendFactory
import org.calyxos.seedvault.core.backends.BackendProperties
import org.calyxos.seedvault.core.backends.saf.SafBackend
class BackendManager(
private val context: Context,
private val settingsManager: SettingsManager,
private val blobCache: BlobCache,
backendFactory: BackendFactory,
) {
@Volatile
private var mBackend: Backend?
@Volatile
private var mBackendProperties: BackendProperties<*>?
val backend: Backend
@Synchronized
get() {
return mBackend ?: error("App plugin was loaded, but still null")
}
val backendProperties: BackendProperties<*>?
@Synchronized
get() {
return mBackendProperties
}
val isOnRemovableDrive: Boolean get() = backendProperties?.isUsb == true
val requiresNetwork: Boolean get() = backendProperties?.requiresNetwork == true
init {
when (settingsManager.storagePluginType) {
StoragePluginType.SAF -> {
val safConfig = settingsManager.getSafProperties() ?: error("No SAF storage saved")
mBackend = backendFactory.createSafBackend(safConfig)
mBackendProperties = safConfig
}
StoragePluginType.WEB_DAV -> {
val webDavProperties =
settingsManager.webDavProperties ?: error("No WebDAV config saved")
mBackend = backendFactory.createWebDavBackend(webDavProperties.config)
mBackendProperties = webDavProperties
}
null -> {
mBackend = null
mBackendProperties = null
}
}
}
fun isValidAppPluginSet(): Boolean {
if (mBackend == null) return false
if (mBackend is SafBackend) {
val storage = settingsManager.getSafProperties() ?: return false
if (storage.isUsb) return true
return permitDiskReads {
storage.getDocumentFile(context).isDirectory
}
}
return true
}
/**
* Changes the storage plugins and current [BackendProperties].
*
* IMPORTANT: Do no call this while current plugins are being used,
* e.g. while backup/restore operation is still running.
*/
@WorkerThread
@Synchronized
fun <T> changePlugins(
backend: Backend,
storageProperties: BackendProperties<T>,
) {
settingsManager.setStorageBackend(backend)
mBackend = backend
mBackendProperties = storageProperties
blobCache.clearLocalCache()
// TODO not critical, but nice to have: clear also local snapshot cache
}
/**
* Check if we are able to do backups now by examining possible pre-conditions
* such as plugged-in flash drive or internet access.
*
* Should be run off the UI thread (ideally I/O) because of disk access.
*
* @return true if a backup is possible, false if not.
*/
@WorkerThread
fun canDoBackupNow(): Boolean {
val storage = backendProperties ?: return false
return !isOnUnavailableUsb() &&
!storage.isUnavailableNetwork(context, settingsManager.useMeteredNetwork)
}
/**
* Checks if storage is on a flash drive.
*
* Should be run off the UI thread (ideally I/O) because of disk access.
*
* @return true if flash drive is not plugged in,
* false if storage isn't on flash drive or it isn't plugged in.
*/
@WorkerThread
fun isOnUnavailableUsb(): Boolean {
val storage = backendProperties ?: return false
val systemContext = context.getStorageContext { storage.isUsb }
return storage.isUnavailableUsb(systemContext)
}
/**
* Retrieves the amount of free space in bytes, or null if unknown.
*/
@WorkerThread
suspend fun getFreeSpace(): Long? {
return try {
backend.getFreeSpace()
} catch (e: Throwable) { // NoClassDefFound isn't an [Exception], can get thrown by dav4jvm
Log.e("StoragePluginManager", "Error getting free space: ", e)
null
}
}
}

View file

@ -1,10 +1,16 @@
package com.stevesoltys.seedvault.transport.restore
/*
* SPDX-FileCopyrightText: 2020 The Calyx Institute
* SPDX-License-Identifier: Apache-2.0
*/
package com.stevesoltys.seedvault.backend
import android.content.pm.PackageInfo
import java.io.IOException
import java.io.InputStream
interface KVRestorePlugin {
@Deprecated("Only for old v0 backup format")
interface LegacyStoragePlugin {
/**
* Return true if there is data stored for the given package.
@ -33,7 +39,22 @@ interface KVRestorePlugin {
suspend fun getInputStreamForRecord(
token: Long,
packageInfo: PackageInfo,
key: String
key: String,
): InputStream
/**
* Return true if there is data stored for the given package.
*/
@Throws(IOException::class)
suspend fun hasDataForFullPackage(token: Long, packageInfo: PackageInfo): Boolean
@Throws(IOException::class)
suspend fun getInputStreamForPackage(token: Long, packageInfo: PackageInfo): InputStream
/**
* Returns an [InputStream] for the given token, for reading an APK that is to be restored.
*/
@Throws(IOException::class)
suspend fun getApkInputStream(token: Long, packageName: String, suffix: String): InputStream
}

View file

@ -1,18 +1,27 @@
package com.stevesoltys.seedvault.plugins.saf
/*
* SPDX-FileCopyrightText: 2020 The Calyx Institute
* SPDX-License-Identifier: Apache-2.0
*/
package com.stevesoltys.seedvault.backend.saf
import android.content.Context
import android.content.pm.PackageInfo
import androidx.annotation.WorkerThread
import androidx.documentfile.provider.DocumentFile
import com.stevesoltys.seedvault.transport.restore.KVRestorePlugin
import com.stevesoltys.seedvault.backend.LegacyStoragePlugin
import java.io.FileNotFoundException
import java.io.IOException
import java.io.InputStream
@Suppress("BlockingMethodInNonBlockingContext")
internal class DocumentsProviderKVRestorePlugin(
@WorkerThread
@Suppress("Deprecation")
internal class DocumentsProviderLegacyPlugin(
private val context: Context,
private val storage: DocumentsStorage
) : KVRestorePlugin {
private val storageGetter: () -> DocumentsStorage,
) : LegacyStoragePlugin {
private val storage get() = storageGetter()
private var packageDir: DocumentFile? = null
private var packageChildren: List<DocumentFile>? = null
@ -47,7 +56,7 @@ internal class DocumentsProviderKVRestorePlugin(
override suspend fun getInputStreamForRecord(
token: Long,
packageInfo: PackageInfo,
key: String
key: String,
): InputStream {
val packageDir = this.packageDir
?: throw AssertionError("No cached packageDir for ${packageInfo.packageName}")
@ -58,4 +67,33 @@ internal class DocumentsProviderKVRestorePlugin(
return storage.getInputStream(keyFile)
}
@Throws(IOException::class)
override suspend fun hasDataForFullPackage(token: Long, packageInfo: PackageInfo): Boolean {
val backupDir = storage.getFullBackupDir(token) ?: return false
return backupDir.findFileBlocking(context, packageInfo.packageName) != null
}
@Throws(IOException::class)
override suspend fun getInputStreamForPackage(
token: Long,
packageInfo: PackageInfo,
): InputStream {
val backupDir = storage.getFullBackupDir(token) ?: throw IOException()
val packageFile =
backupDir.findFileBlocking(context, packageInfo.packageName) ?: throw IOException()
return storage.getInputStream(packageFile)
}
@Throws(IOException::class)
override suspend fun getApkInputStream(
token: Long,
packageName: String,
suffix: String,
): InputStream {
val setDir = storage.getSetDir(token) ?: throw IOException()
val file = setDir.findFileBlocking(context, "$packageName$suffix.apk")
?: throw FileNotFoundException()
return storage.getInputStream(file)
}
}

View file

@ -0,0 +1,27 @@
/*
* SPDX-FileCopyrightText: 2020 The Calyx Institute
* SPDX-License-Identifier: Apache-2.0
*/
package com.stevesoltys.seedvault.backend.saf
import com.stevesoltys.seedvault.backend.LegacyStoragePlugin
import com.stevesoltys.seedvault.settings.SettingsManager
import org.koin.android.ext.koin.androidContext
import org.koin.dsl.module
val storagePluginModuleSaf = module {
single { SafHandler(androidContext(), get(), get(), get()) }
@Suppress("Deprecation")
single<LegacyStoragePlugin> {
DocumentsProviderLegacyPlugin(
context = androidContext(),
storageGetter = {
val safProperties = get<SettingsManager>().getSafProperties()
?: error("No SAF storage")
DocumentsStorage(androidContext(), safProperties)
},
)
}
}

View file

@ -0,0 +1,204 @@
/*
* SPDX-FileCopyrightText: 2020 The Calyx Institute
* SPDX-License-Identifier: Apache-2.0
*/
package com.stevesoltys.seedvault.backend.saf
import android.content.ContentResolver
import android.content.Context
import android.content.pm.PackageInfo
import android.database.ContentObserver
import android.database.Cursor
import android.net.Uri
import android.provider.DocumentsContract.Document.COLUMN_DOCUMENT_ID
import android.provider.DocumentsContract.EXTRA_LOADING
import android.provider.DocumentsContract.buildChildDocumentsUriUsingTree
import android.provider.DocumentsContract.buildDocumentUriUsingTree
import android.provider.DocumentsContract.getDocumentId
import android.util.Log
import androidx.annotation.VisibleForTesting
import androidx.documentfile.provider.DocumentFile
import com.stevesoltys.seedvault.getStorageContext
import kotlinx.coroutines.TimeoutCancellationException
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.suspendCancellableCoroutine
import kotlinx.coroutines.withTimeout
import org.calyxos.seedvault.core.backends.Constants.DIRECTORY_ROOT
import org.calyxos.seedvault.core.backends.saf.SafProperties
import org.calyxos.seedvault.core.backends.saf.getTreeDocumentFile
import java.io.IOException
import java.io.InputStream
import kotlin.coroutines.resume
@Deprecated("")
const val DIRECTORY_FULL_BACKUP = "full"
@Deprecated("")
const val DIRECTORY_KEY_VALUE_BACKUP = "kv"
private val TAG = DocumentsStorage::class.java.simpleName
internal class DocumentsStorage(
private val appContext: Context,
internal val safStorage: SafProperties,
) {
/**
* Attention: This context might be from a different user. Use with care.
*/
private val context: Context get() = appContext.getStorageContext { safStorage.isUsb }
private val contentResolver: ContentResolver get() = context.contentResolver
private var rootBackupDir: DocumentFile? = null
get() = runBlocking {
if (field == null) {
val parent = safStorage.getDocumentFile(context)
field = try {
parent.createOrGetDirectory(context, DIRECTORY_ROOT)
} catch (e: IOException) {
Log.e(TAG, "Error creating root backup dir.", e)
null
}
}
field
}
@Throws(IOException::class)
suspend fun getSetDir(token: Long): DocumentFile? {
return rootBackupDir?.findFileBlocking(context, token.toString())
}
@Throws(IOException::class)
@Suppress("Deprecation")
@Deprecated("Use only for v0 restore")
suspend fun getKVBackupDir(token: Long): DocumentFile? {
return getSetDir(token)?.findFileBlocking(context, DIRECTORY_KEY_VALUE_BACKUP)
}
@Throws(IOException::class)
@Suppress("Deprecation")
@Deprecated("Use only for v0 restore")
suspend fun getFullBackupDir(token: Long): DocumentFile? {
return getSetDir(token)?.findFileBlocking(context, DIRECTORY_FULL_BACKUP)
}
@Throws(IOException::class)
fun getInputStream(file: DocumentFile): InputStream {
return try {
contentResolver.openInputStream(file.uri) ?: throw IOException()
} catch (e: Exception) {
// SAF can throw all sorts of exceptions, so wrap it in IOException
throw IOException(e)
}
}
}
/**
* Checks if a directory already exists and if not, creates it.
*/
@Throws(IOException::class)
suspend fun DocumentFile.createOrGetDirectory(context: Context, name: String): DocumentFile {
return findFileBlocking(context, name) ?: createDirectory(name)?.apply {
if (this.name != name) {
throw IOException("Directory named ${this.name}, but should be $name")
}
} ?: throw IOException()
}
fun DocumentFile.assertRightFile(packageInfo: PackageInfo) {
if (name != packageInfo.packageName) {
throw AssertionError("Expected ${packageInfo.packageName}, but got $name")
}
}
/**
* Works like [DocumentFile.listFiles] except that it waits until the DocumentProvider has a result.
* This prevents getting an empty list even though there are children to be listed.
*/
@Throws(IOException::class)
suspend fun DocumentFile.listFilesBlocking(context: Context): List<DocumentFile> {
val resolver = context.contentResolver
val childrenUri = buildChildDocumentsUriUsingTree(uri, getDocumentId(uri))
val projection = arrayOf(COLUMN_DOCUMENT_ID)
val result = ArrayList<DocumentFile>()
try {
getLoadedCursor {
resolver.query(childrenUri, projection, null, null, null)
}
} catch (e: TimeoutCancellationException) {
throw IOException(e)
}.use { cursor ->
while (cursor.moveToNext()) {
val documentId = cursor.getString(0)
val documentUri = buildDocumentUriUsingTree(uri, documentId)
result.add(getTreeDocumentFile(this, context, documentUri))
}
}
return result
}
/**
* Same as [DocumentFile.findFile] only that it re-queries when the first result was stale.
*
* Most documents providers including Nextcloud are listing the full directory content
* when querying for a specific file in a directory,
* so there is no point in trying to optimize the query by not listing all children.
*/
suspend fun DocumentFile.findFileBlocking(context: Context, displayName: String): DocumentFile? {
val files = try {
listFilesBlocking(context)
} catch (e: Exception) {
Log.e(TAG, "Error finding file blocking", e)
return null
}
for (doc in files) {
if (displayName == doc.name) return doc
}
return null
}
/**
* Returns a cursor for the given query while ensuring that the cursor was loaded.
*
* When the SAF backend is a cloud storage provider (e.g. Nextcloud),
* it can happen that the query returns an outdated (e.g. empty) cursor
* which will only be updated in response to this query.
*
* See: https://commonsware.com/blog/2019/12/14/scoped-storage-stories-listfiles-woe.html
*
* This method uses a [suspendCancellableCoroutine] to wait for the result of a [ContentObserver]
* registered on the cursor in case the cursor is still loading ([EXTRA_LOADING]).
* If the cursor is not loading, it will be returned right away.
*
* @param timeout an optional time-out in milliseconds
* @throws TimeoutCancellationException if there was no result before the time-out
* @throws IOException if the query returns null
*/
@VisibleForTesting
@Throws(IOException::class, TimeoutCancellationException::class)
internal suspend fun getLoadedCursor(timeout: Long = 15_000, query: () -> Cursor?) =
withTimeout(timeout) {
suspendCancellableCoroutine { cont ->
val cursor = query() ?: throw IOException()
cont.invokeOnCancellation { cursor.close() }
val loading = cursor.extras.getBoolean(EXTRA_LOADING, false)
if (loading) {
Log.d(TAG, "Wait for children to get loaded...")
cursor.registerContentObserver(object : ContentObserver(null) {
override fun onChange(selfChange: Boolean, uri: Uri?) {
Log.d(TAG, "Children loaded. Continue...")
cursor.close()
val newCursor = query()
if (newCursor == null) cont.cancel(IOException("query returned no results"))
else cont.resume(newCursor)
}
})
} else {
// not loading, return cursor right away
cont.resume(cursor)
}
}
}

View file

@ -0,0 +1,100 @@
/*
* SPDX-FileCopyrightText: 2024 The Calyx Institute
* SPDX-License-Identifier: Apache-2.0
*/
package com.stevesoltys.seedvault.backend.saf
import android.content.Context
import android.content.Context.USB_SERVICE
import android.content.Intent.FLAG_GRANT_READ_URI_PERMISSION
import android.content.Intent.FLAG_GRANT_WRITE_URI_PERMISSION
import android.hardware.usb.UsbManager
import android.net.Uri
import android.util.Log
import androidx.annotation.WorkerThread
import com.stevesoltys.seedvault.R
import com.stevesoltys.seedvault.backend.BackendManager
import com.stevesoltys.seedvault.isMassStorage
import com.stevesoltys.seedvault.settings.FlashDrive
import com.stevesoltys.seedvault.settings.SettingsManager
import com.stevesoltys.seedvault.ui.storage.StorageOption
import org.calyxos.seedvault.core.backends.BackendFactory
import org.calyxos.seedvault.core.backends.saf.SafProperties
import java.io.IOException
private const val TAG = "SafHandler"
internal class SafHandler(
private val context: Context,
private val backendFactory: BackendFactory,
private val settingsManager: SettingsManager,
private val backendManager: BackendManager,
) {
fun onConfigReceived(uri: Uri, safOption: StorageOption.SafOption): SafProperties {
// persist permission to access backup folder across reboots
val takeFlags = FLAG_GRANT_READ_URI_PERMISSION or FLAG_GRANT_WRITE_URI_PERMISSION
context.contentResolver.takePersistableUriPermission(uri, takeFlags)
return SafProperties(
config = uri,
name = if (safOption.isInternal()) {
val brackets = context.getString(R.string.settings_backup_location_internal)
"${safOption.title} ($brackets)"
} else {
safOption.title
},
isUsb = safOption.isUsb,
requiresNetwork = safOption.requiresNetwork,
rootId = safOption.rootId,
)
}
/**
* Searches if there's really an app backup available in the given storage location.
* Returns true if at least one was found and false otherwise.
*/
@WorkerThread
@Throws(IOException::class)
suspend fun hasAppBackup(safProperties: SafProperties): Boolean {
val backend = backendFactory.createSafBackend(safProperties)
return backend.getAvailableBackupFileHandles().isNotEmpty()
}
fun save(safProperties: SafProperties) {
settingsManager.setSafProperties(safProperties)
if (safProperties.isUsb) {
Log.d(TAG, "Selected storage is a removable USB device.")
val wasSaved = saveUsbDevice()
// reset stored flash drive, if we did not update it
if (!wasSaved) settingsManager.setFlashDrive(null)
} else {
settingsManager.setFlashDrive(null)
}
Log.d(TAG, "New storage location saved: ${safProperties.uri}")
}
private fun saveUsbDevice(): Boolean {
val manager = context.getSystemService(USB_SERVICE) as UsbManager
manager.deviceList.values.forEach { device ->
if (device.isMassStorage()) {
val flashDrive = FlashDrive.from(device)
settingsManager.setFlashDrive(flashDrive)
Log.d(TAG, "Saved flash drive: $flashDrive")
return true
}
}
Log.e(TAG, "No USB device found even though we were expecting one.")
return false
}
@WorkerThread
fun setPlugin(safProperties: SafProperties) {
backendManager.changePlugins(
backend = backendFactory.createSafBackend(safProperties),
storageProperties = safProperties,
)
}
}

View file

@ -0,0 +1,234 @@
/*
* SPDX-FileCopyrightText: 2024 The Calyx Institute
* SPDX-License-Identifier: Apache-2.0
*/
package com.stevesoltys.seedvault.backend.saf
import android.content.Context
import android.content.Intent
import android.content.Intent.ACTION_VIEW
import android.content.Intent.FLAG_ACTIVITY_NEW_TASK
import android.net.Uri
import android.provider.DocumentsContract
import android.provider.DocumentsContract.Document.COLUMN_DISPLAY_NAME
import android.provider.DocumentsContract.Document.COLUMN_DOCUMENT_ID
import com.stevesoltys.seedvault.R
import com.stevesoltys.seedvault.backend.saf.StorageRootResolver.getIcon
import com.stevesoltys.seedvault.ui.storage.AUTHORITY_DAVX5
import com.stevesoltys.seedvault.ui.storage.AUTHORITY_NEXTCLOUD
import com.stevesoltys.seedvault.ui.storage.AUTHORITY_ROUND_SYNC
import com.stevesoltys.seedvault.ui.storage.AUTHORITY_STORAGE
import com.stevesoltys.seedvault.ui.storage.StorageOption
import com.stevesoltys.seedvault.ui.storage.StorageOption.SafOption
private const val DAVX5_PACKAGE = "at.bitfire.davdroid"
private const val DAVX5_ACTIVITY = "at.bitfire.davdroid.ui.webdav.WebdavMountsActivity"
private const val NEXTCLOUD_PACKAGE = "com.nextcloud.client"
private const val NEXTCLOUD_ACTIVITY = "com.owncloud.android.authentication.AuthenticatorActivity"
/**
* A class for storage option placeholders that need to be shown under certain circumstances.
* E.g. a way to install an app when needed for restore.
*/
internal class SafStorageOptions(
private val context: Context,
private val isRestore: Boolean,
private val whitelistedAuthorities: Array<String>,
) {
private val packageManager = context.packageManager
internal fun checkOrAddExtraRoots(roots: ArrayList<StorageOption>) {
checkOrAddUsbRoot(roots)
checkOrAddDavX5Root(roots)
checkOrAddNextCloudRoot(roots)
checkOrAddRoundSyncRoots(roots)
}
private fun checkOrAddUsbRoot(roots: ArrayList<StorageOption>) {
if (doNotInclude(AUTHORITY_STORAGE, roots) { it is SafOption && it.isUsb }) return
val root = SafOption(
authority = AUTHORITY_STORAGE,
rootId = "usb",
documentId = "fake",
icon = getIcon(context, AUTHORITY_STORAGE, "usb", 0),
title = context.getString(R.string.storage_fake_drive_title),
summary = context.getString(R.string.storage_fake_drive_summary),
availableBytes = null,
isUsb = true,
requiresNetwork = false,
enabled = false
)
roots.add(root)
}
/**
* Add a storage root for each child directory at the RoundSync root, if it exists.
*/
private fun checkOrAddRoundSyncRoots(roots: ArrayList<StorageOption>) {
val roundSyncRoot = roots.firstOrNull {
it is SafOption && it.authority == AUTHORITY_ROUND_SYNC
} as? SafOption ?: return
roots.remove(roundSyncRoot)
val childrenUri = DocumentsContract.buildChildDocumentsUriUsingTree(
roundSyncRoot.uri, roundSyncRoot.documentId
)
val projection = arrayOf(COLUMN_DISPLAY_NAME, COLUMN_DOCUMENT_ID)
val cursor = context.contentResolver.query(childrenUri, projection, null, null, null)
cursor?.use {
val nameIndex = cursor.getColumnIndex(COLUMN_DISPLAY_NAME)
val documentIdIndex = cursor.getColumnIndex(COLUMN_DOCUMENT_ID)
while (cursor.moveToNext()) {
val name = cursor.getString(nameIndex)
val documentId = cursor.getString(documentIdIndex)
val childRoot = SafOption(
authority = AUTHORITY_ROUND_SYNC,
rootId = name,
documentId = documentId,
icon = getIcon(context, AUTHORITY_ROUND_SYNC, name, 0),
title = name,
summary = context.getString(R.string.storage_round_sync_summary_prefix) + name,
availableBytes = null,
isUsb = false,
requiresNetwork = true,
enabled = true
)
roots.add(childRoot)
}
}
}
/**
* This adds a fake Dav X5 entry if no real one was found.
*
* If Dav X5 is *not* installed,
* the user will always have the option to install it by clicking the entry.
*
* If it *is* installed and this is restore, the user can set up a new account by clicking.
*/
private fun checkOrAddDavX5Root(roots: ArrayList<StorageOption>) {
if (doNotInclude(AUTHORITY_DAVX5, roots)) return
val intent = Intent().apply {
addFlags(FLAG_ACTIVITY_NEW_TASK)
setClassName(DAVX5_PACKAGE, DAVX5_ACTIVITY)
}
val marketIntent =
Intent(ACTION_VIEW, Uri.parse("market://details?id=$DAVX5_PACKAGE")).apply {
addFlags(FLAG_ACTIVITY_NEW_TASK)
}
val isInstalled = packageManager.resolveActivity(intent, 0) != null
val canInstall = packageManager.resolveActivity(marketIntent, 0) != null
val summaryRes = if (isInstalled) {
if (isRestore) R.string.storage_fake_davx5_summary_installed
else R.string.storage_fake_davx5_summary_unavailable
} else {
if (canInstall) R.string.storage_fake_davx5_summary
else R.string.storage_fake_davx5_summary_unavailable_market
}
val root = SafOption(
authority = AUTHORITY_DAVX5,
rootId = "fake",
documentId = "fake",
icon = getIcon(context, AUTHORITY_DAVX5, "fake", 0),
title = context.getString(R.string.storage_fake_davx5_title),
summary = context.getString(summaryRes),
availableBytes = null,
isUsb = false,
requiresNetwork = true,
enabled = isInstalled || canInstall,
nonDefaultAction = {
if (isInstalled) context.startActivity(intent)
else if (canInstall) context.startActivity(marketIntent)
}
)
roots.add(root)
}
/**
* This adds a fake Nextcloud entry if no real one was found.
*
* If Nextcloud is *not* installed,
* the user will always have the option to install it by clicking the entry.
*
* If it *is* installed and this is restore, the user can set up a new account by clicking.
* FIXME: If this isn't restore, the entry should be disabled,
* because we don't know if there's just no account or an activated passcode
* (which hides existing accounts).
*/
private fun checkOrAddNextCloudRoot(roots: ArrayList<StorageOption>) {
if (doNotInclude(AUTHORITY_NEXTCLOUD, roots)) return
val intent = Intent().apply {
addFlags(FLAG_ACTIVITY_NEW_TASK)
setClassName(NEXTCLOUD_PACKAGE, NEXTCLOUD_ACTIVITY)
// setting a nc:// Uri prevents FirstRunActivity to show
data = Uri.parse("nc://login/server:")
putExtra("onlyAdd", true)
}
val marketIntent =
Intent(ACTION_VIEW, Uri.parse("market://details?id=$NEXTCLOUD_PACKAGE")).apply {
addFlags(FLAG_ACTIVITY_NEW_TASK)
}
val isInstalled = packageManager.resolveActivity(intent, 0) != null
val canInstall = packageManager.resolveActivity(marketIntent, 0) != null
val summaryRes = if (isInstalled) {
if (isRestore) R.string.storage_fake_nextcloud_summary_installed
else R.string.storage_fake_nextcloud_summary_unavailable
} else {
if (canInstall) R.string.storage_fake_nextcloud_summary
else R.string.storage_fake_nextcloud_summary_unavailable_market
}
val root = SafOption(
authority = AUTHORITY_NEXTCLOUD,
rootId = "fake",
documentId = "fake",
icon = getIcon(context, AUTHORITY_NEXTCLOUD, "fake", 0),
title = context.getString(
R.string.storage_not_recommended,
context.getString(R.string.storage_fake_nextcloud_title)
),
summary = context.getString(summaryRes),
availableBytes = null,
isUsb = false,
requiresNetwork = true,
enabled = isInstalled || canInstall,
nonDefaultAction = {
if (isInstalled) context.startActivity(intent)
else if (canInstall) context.startActivity(marketIntent)
}
)
roots.add(root)
}
private fun doNotInclude(
authority: String,
roots: ArrayList<StorageOption>,
doNotIncludeIfTrue: ((StorageOption) -> Boolean)? = null,
): Boolean {
if (!isAuthoritySupported(authority)) return true
for (root in roots) {
if (root !is SafOption) continue
if (root.authority == authority && doNotIncludeIfTrue?.invoke(root) != false) {
return true
}
}
return false
}
private fun isAuthoritySupported(authority: String): Boolean {
// just restrict where to store backups,
// restoring can be more free for forward compatibility
return isRestore || whitelistedAuthorities.contains(authority)
}
}

View file

@ -0,0 +1,179 @@
/*
* SPDX-FileCopyrightText: 2024 The Calyx Institute
* SPDX-License-Identifier: Apache-2.0
*/
package com.stevesoltys.seedvault.backend.saf
import android.Manifest.permission.MANAGE_DOCUMENTS
import android.content.Context
import android.database.Cursor
import android.graphics.drawable.Drawable
import android.net.Uri
import android.os.Environment
import android.os.StatFs
import android.os.UserHandle
import android.provider.DocumentsContract
import android.provider.DocumentsContract.Root.COLUMN_AVAILABLE_BYTES
import android.provider.DocumentsContract.Root.COLUMN_DOCUMENT_ID
import android.provider.DocumentsContract.Root.COLUMN_FLAGS
import android.provider.DocumentsContract.Root.COLUMN_ICON
import android.provider.DocumentsContract.Root.COLUMN_ROOT_ID
import android.provider.DocumentsContract.Root.COLUMN_SUMMARY
import android.provider.DocumentsContract.Root.COLUMN_TITLE
import android.provider.DocumentsContract.Root.FLAG_LOCAL_ONLY
import android.provider.DocumentsContract.Root.FLAG_REMOVABLE_USB
import android.provider.DocumentsContract.Root.FLAG_SUPPORTS_CREATE
import android.provider.DocumentsContract.Root.FLAG_SUPPORTS_IS_CHILD
import android.util.Log
import androidx.appcompat.content.res.AppCompatResources.getDrawable
import com.stevesoltys.seedvault.R
import com.stevesoltys.seedvault.getStorageContext
import com.stevesoltys.seedvault.ui.storage.AUTHORITY_DAVX5
import com.stevesoltys.seedvault.ui.storage.AUTHORITY_DOWNLOADS
import com.stevesoltys.seedvault.ui.storage.AUTHORITY_NEXTCLOUD
import com.stevesoltys.seedvault.ui.storage.AUTHORITY_ROUND_SYNC
import com.stevesoltys.seedvault.ui.storage.AUTHORITY_STORAGE
import com.stevesoltys.seedvault.ui.storage.ROOT_ID_DEVICE
import com.stevesoltys.seedvault.ui.storage.ROOT_ID_HOME
import com.stevesoltys.seedvault.ui.storage.StorageOption.SafOption
internal object StorageRootResolver {
private val TAG = StorageRootResolver::class.java.simpleName
fun getStorageRoots(context: Context, authority: String): List<SafOption> {
val roots = ArrayList<SafOption>()
val rootsUri = DocumentsContract.buildRootsUri(authority)
try {
context.contentResolver.query(rootsUri, null, null, null, null)?.use { cursor ->
while (cursor.moveToNext()) {
val root = getStorageRoot(context, authority, cursor)
if (root != null) roots.add(root)
}
}
// add special system user roots for USB devices
val c = context.getStorageContext {
authority == AUTHORITY_STORAGE && UserHandle.myUserId() != UserHandle.USER_SYSTEM
}
// only proceed if we really got a different [Context], e.g. had permission for it
if (context !== c) {
c.contentResolver.query(rootsUri, null, null, null, null)?.use { cursor ->
while (cursor.moveToNext()) {
// Pass in [context] since it is used to query package manager for app icons
val root = getStorageRoot(context, authority, cursor)
// only add USB storage from system user, no others
if (root != null && root.isUsb) roots.add(root)
}
}
}
} catch (e: Exception) {
Log.w(TAG, "Failed to load some roots from $authority", e)
}
return roots
}
/**
* Used for getting a SafOption when we lack [MANAGE_DOCUMENTS],
* since we are not allowed to use [getStorageRoots] in this case.
*/
fun getFakeStorageRootForUri(context: Context, uri: Uri): SafOption {
val authority = uri.authority ?: throw AssertionError("No authority in $uri")
return SafOption(
authority = authority,
rootId = ROOT_ID_DEVICE,
documentId = DocumentsContract.getTreeDocumentId(uri),
icon = getIcon(context, authority, ROOT_ID_DEVICE, 0),
title = context.getString(R.string.storage_user_selected_location_title),
summary = "Please open a bug if you see this",
availableBytes = null,
isUsb = false, // FIXME not supported without MANAGE_DOCUMENTS permission
requiresNetwork = authority != AUTHORITY_STORAGE && authority != AUTHORITY_DOWNLOADS,
)
}
private fun getStorageRoot(context: Context, authority: String, cursor: Cursor): SafOption? {
val flags = cursor.getInt(COLUMN_FLAGS)
val supportsCreate = flags and FLAG_SUPPORTS_CREATE != 0
val supportsIsChild = flags and FLAG_SUPPORTS_IS_CHILD != 0
if (!supportsCreate || !supportsIsChild) return null
val rootId = cursor.getString(COLUMN_ROOT_ID)!!
if (authority == AUTHORITY_STORAGE && rootId == ROOT_ID_HOME) return null
val documentId = cursor.getString(COLUMN_DOCUMENT_ID) ?: return null
val isUsb = flags and FLAG_REMOVABLE_USB != 0
return SafOption(
authority = authority,
rootId = rootId,
documentId = documentId,
icon = getIcon(context, authority, rootId, cursor.getInt(COLUMN_ICON)),
title = cursor.getString(COLUMN_TITLE)!!,
summary = cursor.getString(COLUMN_SUMMARY),
availableBytes = cursor.getInt(COLUMN_AVAILABLE_BYTES).let { bytes ->
// AOSP 11+ reports -1 instead of null
if (bytes == -1) {
try {
if (isUsb) {
StatFs("/mnt/media_rw/${documentId.trimEnd(':')}").availableBytes
} else if (authority == AUTHORITY_STORAGE && rootId == ROOT_ID_DEVICE) {
StatFs(Environment.getDataDirectory().absolutePath).availableBytes
} else null
} catch (e: Exception) {
Log.e(TAG, "Error getting available bytes for $rootId ", e)
null
}
} else bytes.toLong()
},
isUsb = isUsb,
requiresNetwork = flags and FLAG_LOCAL_ONLY == 0 // not local only == requires network
)
}
private fun Cursor.getString(columnName: String): String? {
val index = getColumnIndex(columnName)
return if (index != -1) getString(index) else null
}
private fun Cursor.getInt(columnName: String): Int {
val index = getColumnIndex(columnName)
return if (index != -1) getInt(index) else 0
}
fun getIcon(context: Context, authority: String, rootId: String, icon: Int): Drawable? {
return getPackageIcon(context, authority, icon) ?: when {
authority == AUTHORITY_STORAGE && rootId == ROOT_ID_DEVICE -> {
getDrawable(context, R.drawable.ic_phone_android)
}
authority == AUTHORITY_STORAGE && rootId != ROOT_ID_HOME -> {
getDrawable(context, R.drawable.ic_usb)
}
authority == AUTHORITY_NEXTCLOUD -> {
getDrawable(context, R.drawable.nextcloud)
}
authority == AUTHORITY_DAVX5 -> {
getDrawable(context, R.drawable.davx5)
}
authority == AUTHORITY_ROUND_SYNC -> {
getDrawable(context, R.drawable.round_sync)
}
else -> null
}
}
private fun getPackageIcon(context: Context, authority: String, icon: Int): Drawable? {
if (icon != 0) {
val pm = context.packageManager
val info = pm.resolveContentProvider(authority, 0)
if (info != null) {
return pm.getDrawable(info.packageName, icon, info.applicationInfo)
}
}
return null
}
}

View file

@ -0,0 +1,97 @@
/*
* SPDX-FileCopyrightText: 2024 The Calyx Institute
* SPDX-License-Identifier: Apache-2.0
*/
package com.stevesoltys.seedvault.backend.webdav
import android.content.Context
import android.util.Log
import androidx.annotation.WorkerThread
import com.stevesoltys.seedvault.R
import com.stevesoltys.seedvault.backend.BackendManager
import com.stevesoltys.seedvault.settings.SettingsManager
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asStateFlow
import org.calyxos.seedvault.core.backends.Backend
import org.calyxos.seedvault.core.backends.BackendFactory
import org.calyxos.seedvault.core.backends.webdav.WebDavConfig
import org.calyxos.seedvault.core.backends.webdav.WebDavProperties
import java.io.IOException
internal sealed interface WebDavConfigState {
object Empty : WebDavConfigState
object Checking : WebDavConfigState
class Success(
val properties: WebDavProperties,
val backend: Backend,
) : WebDavConfigState
class Error(val e: Exception?) : WebDavConfigState
}
private val TAG = WebDavHandler::class.java.simpleName
internal class WebDavHandler(
private val context: Context,
private val backendFactory: BackendFactory,
private val settingsManager: SettingsManager,
private val backendManager: BackendManager,
) {
companion object {
fun createWebDavProperties(context: Context, config: WebDavConfig): WebDavProperties {
val host = config.url.removePrefix("https://")
return WebDavProperties(
config = config,
name = context.getString(R.string.storage_webdav_name, host),
)
}
}
private val mConfigState = MutableStateFlow<WebDavConfigState>(WebDavConfigState.Empty)
val configState = mConfigState.asStateFlow()
suspend fun onConfigReceived(config: WebDavConfig) {
mConfigState.value = WebDavConfigState.Checking
val backend = backendFactory.createWebDavBackend(config)
try {
if (backend.test()) {
val properties = createWebDavProperties(context, config)
mConfigState.value = WebDavConfigState.Success(properties, backend)
} else {
mConfigState.value = WebDavConfigState.Error(null)
}
} catch (e: Exception) {
Log.e(TAG, "Error testing WebDAV config at ${config.url}", e)
mConfigState.value = WebDavConfigState.Error(e)
}
}
fun resetConfigState() {
mConfigState.value = WebDavConfigState.Empty
}
/**
* Searches if there's really an app backup available in the given storage location.
* Returns true if at least one was found and false otherwise.
*/
@WorkerThread
@Throws(IOException::class)
suspend fun hasAppBackup(backend: Backend): Boolean {
return backend.getAvailableBackupFileHandles().isNotEmpty()
}
fun save(properties: WebDavProperties) {
settingsManager.saveWebDavConfig(properties.config)
}
@WorkerThread
fun setPlugin(properties: WebDavProperties, backend: Backend) {
backendManager.changePlugins(
backend = backend,
storageProperties = properties,
)
}
}

View file

@ -0,0 +1,13 @@
/*
* SPDX-FileCopyrightText: 2024 The Calyx Institute
* SPDX-License-Identifier: Apache-2.0
*/
package com.stevesoltys.seedvault.backend.webdav
import org.koin.android.ext.koin.androidContext
import org.koin.dsl.module
val storagePluginModuleWebDav = module {
single { WebDavHandler(androidContext(), get(), get(), get()) }
}

View file

@ -1,3 +1,8 @@
/*
* SPDX-FileCopyrightText: 2020 The Calyx Institute
* SPDX-License-Identifier: Apache-2.0
*/
package com.stevesoltys.seedvault.crypto
import java.security.Key

View file

@ -1,71 +1,117 @@
/*
* SPDX-FileCopyrightText: 2020 The Calyx Institute
* SPDX-License-Identifier: Apache-2.0
*/
package com.stevesoltys.seedvault.crypto
import android.annotation.SuppressLint
import android.content.Context
import android.provider.Settings
import android.provider.Settings.Secure.ANDROID_ID
import com.google.crypto.tink.subtle.AesGcmHkdfStreaming
import com.stevesoltys.seedvault.encodeBase64
import com.stevesoltys.seedvault.header.HeaderReader
import com.stevesoltys.seedvault.header.HeaderWriter
import com.stevesoltys.seedvault.header.MAX_SEGMENT_CLEARTEXT_LENGTH
import com.stevesoltys.seedvault.header.MAX_SEGMENT_LENGTH
import com.stevesoltys.seedvault.header.MAX_VERSION_HEADER_SIZE
import com.stevesoltys.seedvault.header.SegmentHeader
import com.stevesoltys.seedvault.header.VERSION
import com.stevesoltys.seedvault.header.VersionHeader
import org.calyxos.seedvault.core.crypto.CoreCrypto
import org.calyxos.seedvault.core.crypto.CoreCrypto.ALGORITHM_HMAC
import org.calyxos.seedvault.core.crypto.CoreCrypto.deriveKey
import org.calyxos.seedvault.core.toByteArrayFromHex
import org.calyxos.seedvault.core.toHexString
import java.io.EOFException
import java.io.IOException
import java.io.InputStream
import java.io.OutputStream
import javax.crypto.Cipher
import java.nio.ByteBuffer
import java.security.GeneralSecurityException
import java.security.MessageDigest
import java.security.NoSuchAlgorithmException
import java.security.SecureRandom
import javax.crypto.Mac
import javax.crypto.spec.SecretKeySpec
import kotlin.math.min
/**
* A backup stream starts with a version byte followed by an encrypted [VersionHeader].
* A version 1 backup stream uses [AesGcmHkdfStreaming] from the tink library.
*
* A version 0 backup stream starts with a version byte followed by an encrypted [VersionHeader].
*
* The header will be encrypted with AES/GCM to provide authentication.
* It can be written using [encryptHeader] and read using [decryptHeader].
* The latter throws a [SecurityException],
* It can be read using [decryptHeader] which throws a [SecurityException],
* if the expected version and package name do not match the encrypted header.
*
* After the header, follows one or more data segments.
* Each segment begins with a clear-text [SegmentHeader]
* that contains the length of the segment
* and a nonce acting as the initialization vector for the encryption.
* The segment can be written using [encryptSegment] and read using [decryptSegment].
* The latter throws a [SecurityException],
* The segment can be read using [decryptSegment] which throws a [SecurityException],
* if the length of the segment is specified larger than allowed.
*/
interface Crypto {
internal interface Crypto {
/**
* Encrypts a backup stream header ([VersionHeader]) and writes it to the given [OutputStream].
*
* The header using a small segment containing only
* the version number, the package name and (optionally) the key of a key/value stream.
* Returns a ByteArray with bytes retrieved from [SecureRandom].
*/
@Throws(IOException::class)
fun encryptHeader(outputStream: OutputStream, versionHeader: VersionHeader)
fun getRandomBytes(size: Int): ByteArray
/**
* Encrypts a new backup segment from the given cleartext payload
* and writes it to the given [OutputStream].
*
* A segment starts with a [SegmentHeader] which includes the length of the segment
* and a nonce which is used as initialization vector for the encryption.
*
* After the header follows the encrypted payload.
* Larger backup streams such as from a full backup are encrypted in multiple segments
* to avoid having to load the entire stream into memory when doing authenticated encryption.
*
* The given cleartext can later be decrypted
* by calling [decryptSegment] on the same byte stream.
* Returns the ID of the backup repository as a 64 char hex string.
*/
@Throws(IOException::class)
fun encryptSegment(outputStream: OutputStream, cleartext: ByteArray)
val repoId: String
/**
* Like [encryptSegment],
* but if the given cleartext [ByteArray] is larger than [MAX_SEGMENT_CLEARTEXT_LENGTH],
* multiple segments will be written.
* A secret key of size [KEY_SIZE_BYTES]
* only used to create a gear table specific to each main key.
*/
@Throws(IOException::class)
fun encryptMultipleSegments(outputStream: OutputStream, cleartext: ByteArray)
val gearTableKey: ByteArray
fun sha256(bytes: ByteArray): ByteArray
/**
* Returns a [AesGcmHkdfStreaming] encrypting stream
* that gets encrypted and authenticated the given associated data.
*/
@Throws(IOException::class, GeneralSecurityException::class)
fun newEncryptingStream(
outputStream: OutputStream,
associatedData: ByteArray,
): OutputStream
/**
* Returns a [AesGcmHkdfStreaming] decrypting stream
* that gets decrypted and authenticated the given associated data.
*/
@Throws(IOException::class, GeneralSecurityException::class)
fun newDecryptingStream(
inputStream: InputStream,
associatedData: ByteArray,
): InputStream
fun getAdForVersion(version: Byte = VERSION): ByteArray
@Deprecated("only for v1")
fun getNameForPackage(salt: String, packageName: String): String
/**
* Returns the name that identifies an APK in the backup storage plugin.
* @param suffix empty string for normal APKs and the name of the split in case of an APK split
*/
@Deprecated("only for v1")
fun getNameForApk(salt: String, packageName: String, suffix: String = ""): String
/**
* Returns a [AesGcmHkdfStreaming] decrypting stream
* that gets decrypted and authenticated the given associated data.
*/
@Deprecated("only for v1")
@Throws(IOException::class, GeneralSecurityException::class)
fun newDecryptingStreamV1(
inputStream: InputStream,
associatedData: ByteArray,
): InputStream
/**
* Reads and decrypts a [VersionHeader] from the given [InputStream]
@ -75,25 +121,29 @@ interface Crypto {
*
* @return The read [VersionHeader] present in the beginning of the given [InputStream].
*/
@Suppress("Deprecation")
@Deprecated("Use newDecryptingStream instead")
@Throws(IOException::class, SecurityException::class)
fun decryptHeader(
inputStream: InputStream,
expectedVersion: Byte,
expectedPackageName: String,
expectedKey: String? = null
expectedKey: String? = null,
): VersionHeader
/**
* Reads and decrypts a segment from the given [InputStream].
*
* @return The decrypted segment payload as passed into [encryptSegment]
* @return The decrypted segment payload.
*/
@Deprecated("Use newDecryptingStream instead")
@Throws(EOFException::class, IOException::class, SecurityException::class)
fun decryptSegment(inputStream: InputStream): ByteArray
/**
* Like [decryptSegment], but decrypts multiple segments and does not throw [EOFException].
*/
@Deprecated("Use newDecryptingStream instead")
@Throws(IOException::class, SecurityException::class)
fun decryptMultipleSegments(inputStream: InputStream): ByteArray
@ -105,56 +155,100 @@ interface Crypto {
fun verifyBackupKey(seed: ByteArray): Boolean
}
internal const val TYPE_METADATA: Byte = 0x00
internal const val TYPE_BACKUP_KV: Byte = 0x01
internal const val TYPE_BACKUP_FULL: Byte = 0x02
internal const val TYPE_ICONS: Byte = 0x03
@SuppressLint("HardwareIds")
internal class CryptoImpl(
context: Context,
private val keyManager: KeyManager,
private val cipherFactory: CipherFactory,
private val headerWriter: HeaderWriter,
private val headerReader: HeaderReader
private val headerReader: HeaderReader,
private val androidId: String = Settings.Secure.getString(context.contentResolver, ANDROID_ID),
) : Crypto {
@Throws(IOException::class)
override fun encryptHeader(outputStream: OutputStream, versionHeader: VersionHeader) {
val bytes = headerWriter.getEncodedVersionHeader(versionHeader)
private val keyV1: ByteArray by lazy {
deriveKey(keyManager.getMainKey(), "app data key".toByteArray())
}
private val streamKey: ByteArray by lazy {
deriveKey(keyManager.getMainKey(), "app backup stream key".toByteArray())
}
private val secureRandom: SecureRandom by lazy { SecureRandom.getInstanceStrong() }
encryptSegment(outputStream, bytes)
override fun getRandomBytes(size: Int) = ByteArray(size).apply {
secureRandom.nextBytes(this)
}
@Throws(IOException::class)
override fun encryptSegment(outputStream: OutputStream, cleartext: ByteArray) {
val cipher = cipherFactory.createEncryptionCipher()
check(cipher.getOutputSize(cleartext.size) <= MAX_SEGMENT_LENGTH) {
"Cipher's output size ${cipher.getOutputSize(cleartext.size)} is larger" +
"than maximum segment length ($MAX_SEGMENT_LENGTH)"
/**
* The ID of the backup repository tied to this user/device via [ANDROID_ID]
* and the current [KeyManager.getMainKey].
*
* Attention: If the main key ever changes, we need to kill our process,
* so all lazy values that depend on that key or the [gearTableKey] get reinitialized.
*/
override val repoId: String by lazy {
val repoIdKey =
deriveKey(keyManager.getMainKey(), "app backup repoId key".toByteArray())
val hmacHasher: Mac = Mac.getInstance(ALGORITHM_HMAC).apply {
init(SecretKeySpec(repoIdKey, ALGORITHM_HMAC))
}
encryptSegment(cipher, outputStream, cleartext)
hmacHasher.doFinal(androidId.toByteArrayFromHex()).toHexString()
}
@Throws(IOException::class)
override fun encryptMultipleSegments(outputStream: OutputStream, cleartext: ByteArray) {
var end = 0
while (end < cleartext.size) {
val start = end
end = min(cleartext.size, start + MAX_SEGMENT_CLEARTEXT_LENGTH)
val segment = cleartext.copyOfRange(start, end)
val cipher = cipherFactory.createEncryptionCipher()
encryptSegment(cipher, outputStream, segment)
override val gearTableKey: ByteArray
get() = deriveKey(keyManager.getMainKey(), "app backup gear table key".toByteArray())
override fun newEncryptingStream(
outputStream: OutputStream,
associatedData: ByteArray,
): OutputStream = CoreCrypto.newEncryptingStream(streamKey, outputStream, associatedData)
override fun newDecryptingStream(
inputStream: InputStream,
associatedData: ByteArray,
): InputStream = CoreCrypto.newDecryptingStream(streamKey, inputStream, associatedData)
override fun getAdForVersion(version: Byte): ByteArray = ByteBuffer.allocate(1)
.put(version)
.array()
@Deprecated("only for v1")
override fun getNameForPackage(salt: String, packageName: String): String {
return sha256("$salt$packageName".toByteArray()).encodeBase64()
}
@Deprecated("only for v1")
override fun getNameForApk(salt: String, packageName: String, suffix: String): String {
return sha256("${salt}APK$packageName$suffix".toByteArray()).encodeBase64()
}
override fun sha256(bytes: ByteArray): ByteArray {
val messageDigest: MessageDigest = try {
MessageDigest.getInstance("SHA-256")
} catch (e: NoSuchAlgorithmException) {
throw AssertionError(e)
}
messageDigest.update(bytes)
return messageDigest.digest()
}
@Throws(IOException::class)
private fun encryptSegment(cipher: Cipher, outputStream: OutputStream, segment: ByteArray) {
val encrypted = cipher.doFinal(segment)
val segmentHeader = SegmentHeader(encrypted.size.toShort(), cipher.iv)
headerWriter.writeSegmentHeader(outputStream, segmentHeader)
outputStream.write(encrypted)
}
@Deprecated("only for v1")
@Throws(IOException::class, GeneralSecurityException::class)
override fun newDecryptingStreamV1(
inputStream: InputStream,
associatedData: ByteArray,
): InputStream = CoreCrypto.newDecryptingStream(keyV1, inputStream, associatedData)
@Suppress("Deprecation")
@Throws(IOException::class, SecurityException::class)
@Deprecated("Use newDecryptingStream instead")
override fun decryptHeader(
inputStream: InputStream,
expectedVersion: Byte,
expectedPackageName: String,
expectedKey: String?
expectedKey: String?,
): VersionHeader {
val decrypted = decryptSegment(inputStream, MAX_VERSION_HEADER_SIZE)
val header = headerReader.getVersionHeader(decrypted)
@ -178,11 +272,13 @@ internal class CryptoImpl(
return header
}
@Deprecated("Use newDecryptingStream instead")
@Throws(EOFException::class, IOException::class, SecurityException::class)
override fun decryptSegment(inputStream: InputStream): ByteArray {
return decryptSegment(inputStream, MAX_SEGMENT_LENGTH)
}
@Deprecated("Use newDecryptingStream instead")
@Throws(IOException::class, SecurityException::class)
override fun decryptMultipleSegments(inputStream: InputStream): ByteArray {
var result = ByteArray(0)
@ -196,6 +292,7 @@ internal class CryptoImpl(
}
}
@Suppress("Deprecation")
@Throws(EOFException::class, IOException::class, SecurityException::class)
private fun decryptSegment(inputStream: InputStream, maxSegmentLength: Int): ByteArray {
val segmentHeader = headerReader.readSegmentHeader(inputStream)

View file

@ -1,9 +1,15 @@
/*
* SPDX-FileCopyrightText: 2020 The Calyx Institute
* SPDX-License-Identifier: Apache-2.0
*/
package com.stevesoltys.seedvault.crypto
import org.koin.android.ext.koin.androidContext
import org.koin.dsl.module
import java.security.KeyStore
private const val ANDROID_KEY_STORE = "AndroidKeyStore"
const val ANDROID_KEY_STORE = "AndroidKeyStore"
val cryptoModule = module {
factory<CipherFactory> { CipherFactoryImpl(get()) }
@ -15,5 +21,5 @@ val cryptoModule = module {
}
KeyManagerImpl(keyStore)
}
single<Crypto> { CryptoImpl(get(), get(), get()) }
single<Crypto> { CryptoImpl(androidContext(), get(), get(), get()) }
}

View file

@ -1,3 +1,8 @@
/*
* SPDX-FileCopyrightText: 2020 The Calyx Institute
* SPDX-License-Identifier: Apache-2.0
*/
package com.stevesoltys.seedvault.crypto
import android.security.keystore.KeyProperties.BLOCK_MODE_GCM
@ -14,12 +19,12 @@ import javax.crypto.spec.SecretKeySpec
internal const val KEY_SIZE = 256
internal const val KEY_SIZE_BYTES = KEY_SIZE / 8
private const val KEY_ALIAS_BACKUP = "com.stevesoltys.seedvault"
private const val KEY_ALIAS_MAIN = "com.stevesoltys.seedvault.main"
internal const val KEY_ALIAS_BACKUP = "com.stevesoltys.seedvault"
internal const val KEY_ALIAS_MAIN = "com.stevesoltys.seedvault.main"
private const val KEY_ALGORITHM_BACKUP = "AES"
private const val KEY_ALGORITHM_MAIN = "HmacSHA256"
interface KeyManager {
interface KeyManager : org.calyxos.seedvault.core.crypto.KeyManager {
/**
* Store a new backup key derived from the given [seed].
*
@ -52,18 +57,10 @@ interface KeyManager {
* because the key can not leave the [KeyStore]'s hardware security module.
*/
fun getBackupKey(): SecretKey
/**
* Returns the main key, so it can be used for deriving sub-keys.
*
* Note that any attempt to export the key will return null or an empty [ByteArray],
* because the key can not leave the [KeyStore]'s hardware security module.
*/
fun getMainKey(): SecretKey
}
internal class KeyManagerImpl(
private val keyStore: KeyStore
private val keyStore: KeyStore,
) : KeyManager {
override fun storeBackupKey(seed: ByteArray) {
@ -100,7 +97,9 @@ internal class KeyManagerImpl(
.setEncryptionPaddings(ENCRYPTION_PADDING_NONE)
.setRandomizedEncryptionRequired(true)
// unlocking is required only for decryption, so when restoring from backup
builder.setUnlockedDeviceRequired(true)
// FIXME disabled for Android 12 GSI as it crashes when importing the key
// KeyStoreException: Failed to import secret key.
// builder.setUnlockedDeviceRequired(true)
return builder.build()
}

View file

@ -1,8 +1,16 @@
/*
* SPDX-FileCopyrightText: 2020 The Calyx Institute
* SPDX-License-Identifier: Apache-2.0
*/
package com.stevesoltys.seedvault.header
import com.stevesoltys.seedvault.crypto.GCM_AUTHENTICATION_TAG_LENGTH
import com.stevesoltys.seedvault.crypto.TYPE_BACKUP_FULL
import com.stevesoltys.seedvault.crypto.TYPE_BACKUP_KV
import java.nio.ByteBuffer
internal const val VERSION: Byte = 0
internal const val VERSION: Byte = 2
internal const val MAX_PACKAGE_LENGTH_SIZE = 255
internal const val MAX_KEY_LENGTH_SIZE = MAX_PACKAGE_LENGTH_SIZE
internal const val MAX_VERSION_HEADER_SIZE =
@ -12,10 +20,11 @@ internal const val MAX_VERSION_HEADER_SIZE =
* After the first version byte of each backup stream
* must follow followed this header encrypted with authentication.
*/
data class VersionHeader(
@Deprecated("version header is in associated data now")
internal data class VersionHeader(
internal val version: Byte = VERSION, // 1 byte
internal val packageName: String, // ?? bytes (max 255)
internal val key: String? = null // ?? bytes
internal val key: String? = null, // ?? bytes
) {
init {
check(packageName.length <= MAX_PACKAGE_LENGTH_SIZE) {
@ -29,6 +38,24 @@ data class VersionHeader(
}
}
internal fun getADForKV(version: Byte, packageName: String): ByteArray {
val packageNameBytes = packageName.toByteArray()
return ByteBuffer.allocate(2 + packageNameBytes.size)
.put(version)
.put(TYPE_BACKUP_KV)
.put(packageNameBytes)
.array()
}
internal fun getADForFull(version: Byte, packageName: String): ByteArray {
val packageNameBytes = packageName.toByteArray()
return ByteBuffer.allocate(2 + packageNameBytes.size)
.put(version)
.put(TYPE_BACKUP_FULL)
.put(packageNameBytes)
.array()
}
internal const val SEGMENT_LENGTH_SIZE: Int = Short.SIZE_BYTES
internal const val MAX_SEGMENT_LENGTH: Int = Short.MAX_VALUE.toInt()
internal const val MAX_SEGMENT_CLEARTEXT_LENGTH: Int =
@ -39,9 +66,10 @@ internal const val SEGMENT_HEADER_SIZE = SEGMENT_LENGTH_SIZE + IV_SIZE
/**
* Each data segment must start with this header
*/
@Deprecated("Don't do manual segments, use Crypto interface instead.")
class SegmentHeader(
internal val segmentLength: Short, // 2 bytes
internal val nonce: ByteArray // 12 bytes
internal val nonce: ByteArray, // 12 bytes
) {
init {
check(nonce.size == IV_SIZE) {

View file

@ -1,8 +1,12 @@
/*
* SPDX-FileCopyrightText: 2020 The Calyx Institute
* SPDX-License-Identifier: Apache-2.0
*/
package com.stevesoltys.seedvault.header
import org.koin.dsl.module
val headerModule = module {
single<HeaderWriter> { HeaderWriterImpl() }
single<HeaderReader> { HeaderReaderImpl() }
}

View file

@ -1,3 +1,8 @@
/*
* SPDX-FileCopyrightText: 2020 The Calyx Institute
* SPDX-License-Identifier: Apache-2.0
*/
package com.stevesoltys.seedvault.header
import com.stevesoltys.seedvault.Utf8
@ -5,28 +10,37 @@ import java.io.EOFException
import java.io.IOException
import java.io.InputStream
import java.nio.ByteBuffer
import java.security.GeneralSecurityException
interface HeaderReader {
internal interface HeaderReader {
@Throws(IOException::class, UnsupportedVersionException::class)
fun readVersion(inputStream: InputStream): Byte
fun readVersion(inputStream: InputStream, expectedVersion: Byte): Byte
@Suppress("Deprecation")
@Deprecated("For restoring v0 backups only")
@Throws(SecurityException::class)
fun getVersionHeader(byteArray: ByteArray): VersionHeader
@Suppress("Deprecation")
@Deprecated("For restoring v0 backups only")
@Throws(EOFException::class, IOException::class)
fun readSegmentHeader(inputStream: InputStream): SegmentHeader
}
internal class HeaderReaderImpl : HeaderReader {
@Throws(IOException::class, UnsupportedVersionException::class)
override fun readVersion(inputStream: InputStream): Byte {
@Throws(IOException::class, UnsupportedVersionException::class, GeneralSecurityException::class)
override fun readVersion(inputStream: InputStream, expectedVersion: Byte): Byte {
val version = inputStream.read().toByte()
if (version < 0) throw IOException()
if (version > VERSION) throw UnsupportedVersionException(version)
if (expectedVersion != version) throw GeneralSecurityException(
"Expected version ${expectedVersion.toInt()}, but got ${version.toInt()}"
)
return version
}
@Suppress("OverridingDeprecatedMember", "Deprecation")
override fun getVersionHeader(byteArray: ByteArray): VersionHeader {
val buffer = ByteBuffer.wrap(byteArray)
val version = buffer.get()
@ -59,6 +73,7 @@ internal class HeaderReaderImpl : HeaderReader {
}
@Throws(EOFException::class, IOException::class)
@Suppress("OverridingDeprecatedMember", "Deprecation")
override fun readSegmentHeader(inputStream: InputStream): SegmentHeader {
val buffer = ByteArray(SEGMENT_HEADER_SIZE)
val bytesRead = inputStream.read(buffer)

View file

@ -1,51 +0,0 @@
package com.stevesoltys.seedvault.header
import com.stevesoltys.seedvault.Utf8
import java.io.IOException
import java.io.OutputStream
import java.nio.ByteBuffer
interface HeaderWriter {
@Throws(IOException::class)
fun writeVersion(outputStream: OutputStream, header: VersionHeader)
fun getEncodedVersionHeader(header: VersionHeader): ByteArray
@Throws(IOException::class)
fun writeSegmentHeader(outputStream: OutputStream, header: SegmentHeader)
}
internal class HeaderWriterImpl : HeaderWriter {
@Throws(IOException::class)
override fun writeVersion(outputStream: OutputStream, header: VersionHeader) {
val headerBytes = ByteArray(1)
headerBytes[0] = header.version
outputStream.write(headerBytes)
}
override fun getEncodedVersionHeader(header: VersionHeader): ByteArray {
val packageBytes = header.packageName.toByteArray(Utf8)
val keyBytes = header.key?.toByteArray(Utf8)
val size = 1 + 2 + packageBytes.size + 2 + (keyBytes?.size ?: 0)
return ByteBuffer.allocate(size).apply {
put(header.version)
putShort(packageBytes.size.toShort())
put(packageBytes)
if (keyBytes == null) {
putShort(0.toShort())
} else {
putShort(keyBytes.size.toShort())
put(keyBytes)
}
}.array()
}
override fun writeSegmentHeader(outputStream: OutputStream, header: SegmentHeader) {
val buffer = ByteBuffer.allocate(SEGMENT_HEADER_SIZE)
.putShort(header.segmentLength)
.put(header.nonce)
outputStream.write(buffer.array())
}
}

View file

@ -1,30 +1,67 @@
/*
* SPDX-FileCopyrightText: 2020 The Calyx Institute
* SPDX-License-Identifier: Apache-2.0
*/
package com.stevesoltys.seedvault.metadata
import android.content.pm.ApplicationInfo.FLAG_STOPPED
import android.os.Build
import com.stevesoltys.seedvault.crypto.TYPE_METADATA
import com.stevesoltys.seedvault.encodeBase64
import com.stevesoltys.seedvault.header.VERSION
import com.stevesoltys.seedvault.metadata.PackageState.UNKNOWN_ERROR
import java.io.InputStream
import com.stevesoltys.seedvault.proto.Snapshot
import com.stevesoltys.seedvault.repo.hexFromProto
import com.stevesoltys.seedvault.worker.BASE_SPLIT
import org.calyxos.backup.storage.crypto.StreamCrypto.toByteArray
import java.nio.ByteBuffer
typealias PackageMetadataMap = HashMap<String, PackageMetadata>
data class BackupMetadata(
internal val version: Byte = VERSION,
internal val token: Long,
internal val salt: String,
internal var time: Long = 0L,
internal val androidVersion: Int = Build.VERSION.SDK_INT,
internal val androidIncremental: String = Build.VERSION.INCREMENTAL,
internal val deviceName: String = "${Build.MANUFACTURER} ${Build.MODEL}",
internal val packageMetadataMap: PackageMetadataMap = PackageMetadataMap()
)
internal var d2dBackup: Boolean = false,
internal val packageMetadataMap: PackageMetadataMap = PackageMetadataMap(),
) {
companion object {
fun fromSnapshot(s: Snapshot) = BackupMetadata(
version = s.version.toByte(),
token = s.token,
salt = "",
time = s.token,
androidVersion = s.sdkInt,
androidIncremental = s.androidIncremental,
deviceName = "${s.name} - ${s.user}",
d2dBackup = s.d2D,
packageMetadataMap = s.appsMap.mapValues { (_, app) ->
PackageMetadata.fromSnapshot(app)
} as PackageMetadataMap
)
}
val size: Long
get() = packageMetadataMap.values.sumOf { m ->
(m.size ?: 0L) + (m.splits?.sumOf { it.size ?: 0L } ?: 0L)
}
}
internal const val JSON_METADATA = "@meta@"
internal const val JSON_METADATA_VERSION = "version"
internal const val JSON_METADATA_TOKEN = "token"
internal const val JSON_METADATA_SALT = "salt"
internal const val JSON_METADATA_TIME = "time"
internal const val JSON_METADATA_SDK_INT = "sdk_int"
internal const val JSON_METADATA_INCREMENTAL = "incremental"
internal const val JSON_METADATA_NAME = "name"
internal const val JSON_METADATA_D2D_BACKUP = "d2d_backup"
enum class PackageState {
/**
@ -67,27 +104,84 @@ data class PackageMetadata(
*/
internal var time: Long = 0L,
internal var state: PackageState = UNKNOWN_ERROR,
internal var backupType: BackupType? = null,
internal var size: Long? = null,
internal var name: CharSequence? = null,
internal val system: Boolean = false,
internal val isLaunchableSystemApp: Boolean = false,
internal val version: Long? = null,
internal val installer: String? = null,
internal val splits: List<ApkSplit>? = null,
internal val baseApkChunkIds: List<String>? = null, // used for v2
internal val chunkIds: List<String>? = null, // used for v2
internal val sha256: String? = null,
internal val signatures: List<String>? = null
internal val signatures: List<String>? = null,
) {
companion object {
fun fromSnapshot(app: Snapshot.App) = PackageMetadata(
time = app.time,
backupType = app.type.toBackupType(),
name = app.name,
chunkIds = app.chunkIdsList.hexFromProto(),
system = app.system,
isLaunchableSystemApp = app.launchableSystemApp,
version = app.apk.versionCode,
installer = app.apk.installer.takeIf { it.isNotEmpty() },
baseApkChunkIds = run {
val baseChunk = app.apk.splitsList.find { it.name == BASE_SPLIT }
if (baseChunk == null || baseChunk.chunkIdsCount == 0) {
null
} else {
baseChunk.chunkIdsList.hexFromProto()
}
},
splits = app.apk.splitsList.filter { it.name != BASE_SPLIT }.map {
ApkSplit(
name = it.name,
size = null,
sha256 = "",
chunkIds = if (it.chunkIdsCount == 0) null else it.chunkIdsList.hexFromProto()
)
}.takeIf { it.isNotEmpty() }, // expected null if there are no splits
sha256 = null,
signatures = app.apk.signaturesList.map { it.toByteArray().encodeBase64() }.takeIf {
it.isNotEmpty()
},
)
fun Snapshot.BackupType.toBackupType() = when (this) {
Snapshot.BackupType.FULL -> BackupType.FULL
Snapshot.BackupType.KV -> BackupType.KV
else -> null
}
}
val isInternalSystem: Boolean = system && !isLaunchableSystemApp
fun hasApk(): Boolean {
return version != null && sha256 != null && signatures != null
return version != null && // v2 doesn't use sha256 here
(sha256 != null || baseApkChunkIds?.isNotEmpty() == true) &&
signatures != null
}
}
data class ApkSplit(
val name: String,
val sha256: String
val size: Long?,
val sha256: String,
val chunkIds: List<String>? = null, // used for v2
// There's also a revisionCode, but it doesn't seem to be used just yet
)
enum class BackupType { KV, FULL }
internal const val JSON_PACKAGE_TIME = "time"
internal const val JSON_PACKAGE_BACKUP_TYPE = "backupType"
internal const val JSON_PACKAGE_STATE = "state"
internal const val JSON_PACKAGE_SIZE = "size"
internal const val JSON_PACKAGE_APP_NAME = "name"
internal const val JSON_PACKAGE_SYSTEM = "system"
internal const val JSON_PACKAGE_SYSTEM_LAUNCHER = "systemLauncher"
internal const val JSON_PACKAGE_VERSION = "version"
internal const val JSON_PACKAGE_INSTALLER = "installer"
internal const val JSON_PACKAGE_SPLITS = "splits"
@ -97,16 +191,8 @@ internal const val JSON_PACKAGE_SIGNATURES = "signatures"
internal class DecryptionFailedException(cause: Throwable) : Exception(cause)
class EncryptedBackupMetadata private constructor(
val token: Long,
val inputStream: InputStream?,
val error: Boolean
) {
constructor(token: Long, inputStream: InputStream) : this(token, inputStream, false)
/**
* Indicates that there was an error retrieving the encrypted backup metadata.
*/
constructor(token: Long) : this(token, null, true)
}
internal fun getAD(version: Byte, token: Long) = ByteBuffer.allocate(2 + 8)
.put(version)
.put(TYPE_METADATA)
.put(token.toByteArray())
.array()

View file

@ -1,3 +1,8 @@
/*
* SPDX-FileCopyrightText: 2020 The Calyx Institute
* SPDX-License-Identifier: Apache-2.0
*/
package com.stevesoltys.seedvault.metadata
import android.content.Context
@ -6,15 +11,8 @@ import android.content.pm.PackageInfo
import android.util.Log
import androidx.annotation.VisibleForTesting
import androidx.annotation.WorkerThread
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.distinctUntilChanged
import com.stevesoltys.seedvault.Clock
import com.stevesoltys.seedvault.metadata.PackageState.APK_AND_DATA
import com.stevesoltys.seedvault.metadata.PackageState.NOT_ALLOWED
import com.stevesoltys.seedvault.metadata.PackageState.NO_DATA
import com.stevesoltys.seedvault.metadata.PackageState.WAS_STOPPED
import com.stevesoltys.seedvault.transport.backup.isSystemApp
import java.io.FileNotFoundException
import java.io.IOException
import java.io.OutputStream
@ -23,117 +21,63 @@ private val TAG = MetadataManager::class.java.simpleName
@VisibleForTesting
internal const val METADATA_CACHE_FILE = "metadata.cache"
internal const val METADATA_SALT_SIZE = 32
@WorkerThread
class MetadataManager(
internal class MetadataManager(
private val context: Context,
private val clock: Clock,
private val metadataWriter: MetadataWriter,
private val metadataReader: MetadataReader
private val metadataReader: MetadataReader,
) {
private val uninitializedMetadata = BackupMetadata(token = 0L)
private val uninitializedMetadata = BackupMetadata(token = -42L, salt = "foo bar")
private var metadata: BackupMetadata = uninitializedMetadata
get() {
if (field == uninitializedMetadata) {
field = try {
getMetadataFromCache() ?: throw IOException()
val m = getMetadataFromCache() ?: throw IOException()
if (m == uninitializedMetadata) m.copy(salt = "initialized")
else m
} catch (e: IOException) {
// If this happens, it is hard to recover from this. Let's hope it never does.
throw AssertionError("Error reading metadata from cache", e)
// This can happen if the storage location ran out of space
// or the app process got killed while writing the file.
// It is hard to recover from this, so we try as best as we can here:
Log.e(TAG, "ERROR getting metadata cache, creating new file ", e)
uninitializedMetadata.copy(salt = "initialized")
}
mLastBackupTime.postValue(field.time)
}
return field
}
/**
* Call this when initializing a new device.
*
* Existing [BackupMetadata] will be cleared, use the given new token,
* and written encrypted to the given [OutputStream] as well as the internal cache.
*/
@Synchronized
@Throws(IOException::class)
fun onDeviceInitialization(token: Long, metadataOutputStream: OutputStream) {
modifyMetadata(metadataOutputStream) {
metadata = BackupMetadata(token = token)
}
}
/**
* Call this after a package's APK has been backed up successfully.
*
* It updates the packages' metadata
* and writes it encrypted to the given [OutputStream] as well as the internal cache.
*
* Closing the [OutputStream] is the responsibility of the caller.
*/
@Synchronized
@Throws(IOException::class)
fun onApkBackedUp(
packageInfo: PackageInfo,
packageMetadata: PackageMetadata,
metadataOutputStream: OutputStream
) {
val packageName = packageInfo.packageName
metadata.packageMetadataMap[packageName]?.let {
check(packageMetadata.version != null) {
"APK backup returned version null"
}
check(it.version == null || it.version < packageMetadata.version) {
"APK backup backed up the same or a smaller version:" +
"was ${it.version} is ${packageMetadata.version}"
}
}
val oldPackageMetadata = metadata.packageMetadataMap[packageName]
?: PackageMetadata()
// only allow state change if backup of this package is not allowed,
// because we need to change from the default of UNKNOWN_ERROR here,
// but otherwise don't want to modify the state since set elsewhere.
val newState =
if (packageMetadata.state == NOT_ALLOWED || packageMetadata.state == WAS_STOPPED) {
packageMetadata.state
} else {
oldPackageMetadata.state
}
modifyMetadata(metadataOutputStream) {
metadata.packageMetadataMap[packageName] = oldPackageMetadata.copy(
state = newState,
system = packageInfo.isSystemApp(),
version = packageMetadata.version,
installer = packageMetadata.installer,
splits = packageMetadata.splits,
sha256 = packageMetadata.sha256,
signatures = packageMetadata.signatures
)
}
}
/**
* Call this after a package has been backed up successfully.
*
* It updates the packages' metadata
* and writes it encrypted to the given [OutputStream] as well as the internal cache.
*
* Closing the [OutputStream] is the responsibility of the caller.
* It updates the packages' metadata.
*/
@Synchronized
@Throws(IOException::class)
fun onPackageBackedUp(packageInfo: PackageInfo, metadataOutputStream: OutputStream) {
fun onPackageBackedUp(
packageInfo: PackageInfo,
type: BackupType?,
size: Long?,
) {
val packageName = packageInfo.packageName
modifyMetadata(metadataOutputStream) {
modifyCachedMetadata {
val now = clock.time()
metadata.time = now
if (metadata.packageMetadataMap.containsKey(packageName)) {
metadata.packageMetadataMap[packageName]!!.time = now
metadata.packageMetadataMap[packageName]!!.state = APK_AND_DATA
} else {
metadata.packageMetadataMap[packageName] = PackageMetadata(
metadata.packageMetadataMap.getOrPut(packageName) {
PackageMetadata(
time = now,
state = APK_AND_DATA,
system = packageInfo.isSystemApp()
backupType = type,
size = size,
)
}.apply {
time = now
state = APK_AND_DATA
backupType = type
// don't override a previous K/V size, if there were no K/V changes
if (size != null) this.size = size
}
}
}
@ -149,29 +93,60 @@ class MetadataManager(
internal fun onPackageBackupError(
packageInfo: PackageInfo,
packageState: PackageState,
metadataOutputStream: OutputStream
backupType: BackupType? = null,
) {
check(packageState != APK_AND_DATA) { "Backup Error with non-error package state." }
val packageName = packageInfo.packageName
modifyMetadata(metadataOutputStream) {
if (metadata.packageMetadataMap.containsKey(packageName)) {
metadata.packageMetadataMap[packageName]!!.state = packageState
} else {
metadata.packageMetadataMap[packageName] = PackageMetadata(
modifyCachedMetadata {
metadata.packageMetadataMap.getOrPut(packageInfo.packageName) {
PackageMetadata(
time = 0L,
state = packageState,
system = packageInfo.isSystemApp()
backupType = backupType,
name = packageInfo.applicationInfo?.loadLabel(context.packageManager),
)
}.state = packageState
}
}
/**
* Call this for all packages we can not back up for some reason.
*
* It updates the packages' local metadata.
*/
@Synchronized
@Throws(IOException::class)
internal fun onPackageDoesNotGetBackedUp(
packageInfo: PackageInfo,
packageState: PackageState,
) = modifyCachedMetadata {
metadata.packageMetadataMap.getOrPut(packageInfo.packageName) {
PackageMetadata(
time = 0L,
state = packageState,
name = packageInfo.applicationInfo?.loadLabel(context.packageManager),
)
}.apply {
state = packageState
// update name, if none was set, yet (can happen while migrating to storing names)
if (this.name == null) {
this.name = packageInfo.applicationInfo?.loadLabel(context.packageManager)
}
}
}
@Synchronized
fun getPackageMetadata(packageName: String): PackageMetadata? {
return metadata.packageMetadataMap[packageName]?.copy()
}
@Throws(IOException::class)
private fun modifyMetadata(metadataOutputStream: OutputStream, modFun: () -> Unit) {
val oldMetadata = metadata.copy()
private fun modifyCachedMetadata(modFun: () -> Unit) {
val oldMetadata = metadata.copy(
// copy map, otherwise it will re-use same reference
packageMetadataMap = PackageMetadataMap(metadata.packageMetadataMap),
)
try {
modFun.invoke()
metadataWriter.write(metadata, metadataOutputStream)
writeMetadataToCache()
} catch (e: IOException) {
Log.w(TAG, "Error writing metadata to storage", e)
@ -179,47 +154,6 @@ class MetadataManager(
metadata = oldMetadata
throw IOException(e)
}
mLastBackupTime.postValue(metadata.time)
}
/**
* Returns the current backup token.
*
* If the token is 0L, it is not yet initialized and must not be used for anything.
*/
@Synchronized
@Deprecated(
"Responsibility for current token moved to SettingsManager",
ReplaceWith("settingsManager.getToken()")
)
fun getBackupToken(): Long = metadata.token
/**
* Returns the last backup time in unix epoch milli seconds.
*
* Note that this might be a blocking I/O call.
*/
@Synchronized
fun getLastBackupTime(): Long = mLastBackupTime.value ?: metadata.time
private val mLastBackupTime = MutableLiveData<Long>()
internal val lastBackupTime: LiveData<Long> = mLastBackupTime.distinctUntilChanged()
@Synchronized
fun getPackageMetadata(packageName: String): PackageMetadata? {
return metadata.packageMetadataMap[packageName]?.copy()
}
@Synchronized
fun getPackagesNumBackedUp(): Int {
// FIXME we are under-reporting packages here,
// because we have no way to also include upgraded system apps
return metadata.packageMetadataMap.filter { (_, packageMetadata) ->
!packageMetadata.system && ( // ignore system apps
packageMetadata.state == APK_AND_DATA || // either full success
packageMetadata.state == NO_DATA // or apps that simply had no data
)
}.count()
}
@Synchronized

View file

@ -1,3 +1,8 @@
/*
* SPDX-FileCopyrightText: 2020 The Calyx Institute
* SPDX-License-Identifier: Apache-2.0
*/
package com.stevesoltys.seedvault.metadata
import org.koin.android.ext.koin.androidContext
@ -5,6 +10,6 @@ import org.koin.dsl.module
val metadataModule = module {
single { MetadataManager(androidContext(), get(), get(), get()) }
single<MetadataWriter> { MetadataWriterImpl(get()) }
single<MetadataWriter> { MetadataWriterImpl() }
single<MetadataReader> { MetadataReaderImpl(get()) }
}

View file

@ -1,3 +1,8 @@
/*
* SPDX-FileCopyrightText: 2020 The Calyx Institute
* SPDX-License-Identifier: Apache-2.0
*/
package com.stevesoltys.seedvault.metadata
import com.stevesoltys.seedvault.Utf8
@ -14,6 +19,7 @@ import org.json.JSONException
import org.json.JSONObject
import java.io.IOException
import java.io.InputStream
import java.security.GeneralSecurityException
import javax.crypto.AEADBadTagException
interface MetadataReader {
@ -30,7 +36,7 @@ interface MetadataReader {
fun decode(
bytes: ByteArray,
expectedVersion: Byte? = null,
expectedToken: Long? = null
expectedToken: Long? = null,
): BackupMetadata
}
@ -47,19 +53,37 @@ internal class MetadataReaderImpl(private val crypto: Crypto) : MetadataReader {
val version = inputStream.read().toByte()
if (version < 0) throw IOException()
if (version > VERSION) throw UnsupportedVersionException(version)
if (version == 0.toByte()) return readMetadataV0(inputStream, expectedToken)
val metadataBytes = try {
crypto.newDecryptingStreamV1(inputStream, getAD(version, expectedToken)).readBytes()
} catch (e: GeneralSecurityException) {
throw DecryptionFailedException(e)
}
return decode(metadataBytes, version, expectedToken)
}
@Throws(
SecurityException::class,
DecryptionFailedException::class,
UnsupportedVersionException::class,
IOException::class
)
@Suppress("Deprecation")
private fun readMetadataV0(inputStream: InputStream, expectedToken: Long): BackupMetadata {
val metadataBytes = try {
crypto.decryptMultipleSegments(inputStream)
} catch (e: AEADBadTagException) {
throw DecryptionFailedException(e)
}
return decode(metadataBytes, version, expectedToken)
return decode(metadataBytes, 0.toByte(), expectedToken)
}
@Throws(SecurityException::class)
override fun decode(
bytes: ByteArray,
expectedVersion: Byte?,
expectedToken: Long?
expectedToken: Long?,
): BackupMetadata {
// NOTE: We don't do extensive validation of the parsed input here,
// because it was encrypted with authentication, so we should be able to trust it.
@ -70,14 +94,14 @@ internal class MetadataReaderImpl(private val crypto: Crypto) : MetadataReader {
val json = JSONObject(bytes.toString(Utf8))
// get backup metadata and check expectations
val meta = json.getJSONObject(JSON_METADATA)
val version = meta.getInt(JSON_METADATA_VERSION).toByte()
val version = meta.optInt(JSON_METADATA_VERSION, VERSION.toInt()).toByte()
if (expectedVersion != null && version != expectedVersion) {
throw SecurityException(
"Invalid version '${version.toInt()}' in metadata," +
"expected '${expectedVersion.toInt()}'."
)
}
val token = meta.getLong(JSON_METADATA_TOKEN)
val token = meta.optLong(JSON_METADATA_TOKEN, 0)
if (expectedToken != null && token != expectedToken) throw SecurityException(
"Invalid token '$token' in metadata, expected '$expectedToken'."
)
@ -94,6 +118,15 @@ internal class MetadataReaderImpl(private val crypto: Crypto) : MetadataReader {
WAS_STOPPED.name -> WAS_STOPPED
else -> UNKNOWN_ERROR
}
val pBackupType = when (p.optString(JSON_PACKAGE_BACKUP_TYPE)) {
BackupType.KV.name -> BackupType.KV
BackupType.FULL.name -> BackupType.FULL
// we can't fail when format version is 0,
// because when only backing up the APK for example, there's no type
else -> null
}
val pSize = p.optLong(JSON_PACKAGE_SIZE, -1L)
val pName = p.optString(JSON_PACKAGE_APP_NAME)
val pSystem = p.optBoolean(JSON_PACKAGE_SYSTEM, false)
val pVersion = p.optLong(JSON_PACKAGE_VERSION, 0L)
val pInstaller = p.optString(JSON_PACKAGE_INSTALLER)
@ -109,7 +142,11 @@ internal class MetadataReaderImpl(private val crypto: Crypto) : MetadataReader {
packageMetadataMap[packageName] = PackageMetadata(
time = p.getLong(JSON_PACKAGE_TIME),
state = pState,
backupType = pBackupType,
size = if (pSize < 0L) null else pSize,
name = if (pName == "") null else pName,
system = pSystem,
isLaunchableSystemApp = p.optBoolean(JSON_PACKAGE_SYSTEM_LAUNCHER, false),
version = if (pVersion == 0L) null else pVersion,
installer = if (pInstaller == "") null else pInstaller,
splits = getSplits(p),
@ -120,11 +157,13 @@ internal class MetadataReaderImpl(private val crypto: Crypto) : MetadataReader {
return BackupMetadata(
version = version,
token = token,
time = meta.getLong(JSON_METADATA_TIME),
androidVersion = meta.getInt(JSON_METADATA_SDK_INT),
androidIncremental = meta.getString(JSON_METADATA_INCREMENTAL),
deviceName = meta.getString(JSON_METADATA_NAME),
packageMetadataMap = packageMetadataMap
salt = if (version == 0.toByte()) "" else meta.optString(JSON_METADATA_SALT, ""),
time = meta.optLong(JSON_METADATA_TIME, -1),
androidVersion = meta.optInt(JSON_METADATA_SDK_INT, 0),
androidIncremental = meta.optString(JSON_METADATA_INCREMENTAL),
deviceName = meta.optString(JSON_METADATA_NAME),
d2dBackup = meta.optBoolean(JSON_METADATA_D2D_BACKUP, false),
packageMetadataMap = packageMetadataMap,
)
} catch (e: JSONException) {
throw SecurityException(e)
@ -138,6 +177,9 @@ internal class MetadataReaderImpl(private val crypto: Crypto) : MetadataReader {
val jsonApkSplit = jsonSplits.getJSONObject(i)
val apkSplit = ApkSplit(
name = jsonApkSplit.getString(JSON_PACKAGE_SPLIT_NAME),
size = jsonApkSplit.optLong(JSON_PACKAGE_SIZE, -1L).let {
if (it < 0L) null else it
},
sha256 = jsonApkSplit.getString(JSON_PACKAGE_SHA256)
)
splits.add(apkSplit)

View file

@ -1,38 +1,23 @@
/*
* SPDX-FileCopyrightText: 2020 The Calyx Institute
* SPDX-License-Identifier: Apache-2.0
*/
package com.stevesoltys.seedvault.metadata
import com.stevesoltys.seedvault.Utf8
import com.stevesoltys.seedvault.crypto.Crypto
import com.stevesoltys.seedvault.metadata.PackageState.APK_AND_DATA
import org.json.JSONArray
import org.json.JSONObject
import java.io.IOException
import java.io.OutputStream
interface MetadataWriter {
@Throws(IOException::class)
fun write(metadata: BackupMetadata, outputStream: OutputStream)
fun encode(metadata: BackupMetadata): ByteArray
}
internal class MetadataWriterImpl(private val crypto: Crypto) : MetadataWriter {
@Throws(IOException::class)
override fun write(metadata: BackupMetadata, outputStream: OutputStream) {
outputStream.write(ByteArray(1).apply { this[0] = metadata.version })
crypto.encryptMultipleSegments(outputStream, encode(metadata))
}
internal class MetadataWriterImpl : MetadataWriter {
override fun encode(metadata: BackupMetadata): ByteArray {
val json = JSONObject().apply {
put(JSON_METADATA, JSONObject().apply {
put(JSON_METADATA_VERSION, metadata.version.toInt())
put(JSON_METADATA_TOKEN, metadata.token)
put(JSON_METADATA_TIME, metadata.time)
put(JSON_METADATA_SDK_INT, metadata.androidVersion)
put(JSON_METADATA_INCREMENTAL, metadata.androidIncremental)
put(JSON_METADATA_NAME, metadata.deviceName)
})
put(JSON_METADATA, JSONObject())
}
for ((packageName, packageMetadata) in metadata.packageMetadataMap) {
json.put(packageName, JSONObject().apply {
@ -40,24 +25,16 @@ internal class MetadataWriterImpl(private val crypto: Crypto) : MetadataWriter {
if (packageMetadata.state != APK_AND_DATA) {
put(JSON_PACKAGE_STATE, packageMetadata.state.name)
}
if (packageMetadata.system) {
put(JSON_PACKAGE_SYSTEM, packageMetadata.system)
// We can't require a backup type in metadata at this point,
// only when version > 0 and we have actual restore data
if (packageMetadata.backupType != null) {
put(JSON_PACKAGE_BACKUP_TYPE, packageMetadata.backupType!!.name)
}
packageMetadata.version?.let { put(JSON_PACKAGE_VERSION, it) }
packageMetadata.installer?.let { put(JSON_PACKAGE_INSTALLER, it) }
packageMetadata.splits?.let { splits ->
put(JSON_PACKAGE_SPLITS, JSONArray().apply {
for (split in splits) put(JSONObject().apply {
put(JSON_PACKAGE_SPLIT_NAME, split.name)
put(JSON_PACKAGE_SHA256, split.sha256)
})
})
if (packageMetadata.size != null) {
put(JSON_PACKAGE_SIZE, packageMetadata.size)
}
packageMetadata.sha256?.let { put(JSON_PACKAGE_SHA256, it) }
packageMetadata.signatures?.let { put(JSON_PACKAGE_SIGNATURES, JSONArray(it)) }
})
}
return json.toString().toByteArray(Utf8)
}
}

View file

@ -1,71 +0,0 @@
package com.stevesoltys.seedvault.plugins.saf
import android.content.Context
import android.content.pm.PackageInfo
import android.content.pm.PackageManager
import com.stevesoltys.seedvault.transport.backup.BackupPlugin
import com.stevesoltys.seedvault.transport.backup.FullBackupPlugin
import com.stevesoltys.seedvault.transport.backup.KVBackupPlugin
import java.io.IOException
import java.io.OutputStream
private const val MIME_TYPE_APK = "application/vnd.android.package-archive"
@Suppress("BlockingMethodInNonBlockingContext")
internal class DocumentsProviderBackupPlugin(
private val context: Context,
private val storage: DocumentsStorage,
override val kvBackupPlugin: KVBackupPlugin,
override val fullBackupPlugin: FullBackupPlugin
) : BackupPlugin {
private val packageManager: PackageManager = context.packageManager
@Throws(IOException::class)
override suspend fun startNewRestoreSet(token: Long) {
// reset current storage
storage.reset(token)
// get or create root backup dir
storage.rootBackupDir ?: throw IOException()
}
@Throws(IOException::class)
override suspend fun initializeDevice() {
// wipe existing data
storage.getSetDir()?.deleteContents(context)
// reset storage without new token, so folders get recreated
// otherwise stale DocumentFiles will hang around
storage.reset(null)
// create backup folders
storage.currentKvBackupDir ?: throw IOException()
storage.currentFullBackupDir ?: throw IOException()
}
@Throws(IOException::class)
override suspend fun getMetadataOutputStream(): OutputStream {
val setDir = storage.getSetDir() ?: throw IOException()
val metadataFile = setDir.createOrGetFile(context, FILE_BACKUP_METADATA)
return storage.getOutputStream(metadataFile)
}
@Throws(IOException::class)
override suspend fun getApkOutputStream(
packageInfo: PackageInfo,
suffix: String
): OutputStream {
val setDir = storage.getSetDir() ?: throw IOException()
val name = "${packageInfo.packageName}$suffix.apk"
val file = setDir.createOrGetFile(context, name, MIME_TYPE_APK)
return storage.getOutputStream(file)
}
override val providerPackageName: String? by lazy {
val authority = storage.getAuthority() ?: return@lazy null
val providerInfo = packageManager.resolveContentProvider(authority, 0) ?: return@lazy null
providerInfo.packageName
}
}

Some files were not shown because too many files have changed in this diff Show more