Merge branch 'master' into master
This commit is contained in:
commit
87a1dd155f
248 changed files with 11209 additions and 435 deletions
9
.gitignore
vendored
9
.gitignore
vendored
|
|
@ -6,11 +6,12 @@ hs_err_pid*
|
|||
|
||||
## Intellij
|
||||
out/
|
||||
lib/
|
||||
/lib/
|
||||
.idea/*
|
||||
!.idea/runConfigurations*
|
||||
!.idea/inspectionProfiles*
|
||||
!.idea/codeStyles*
|
||||
!.idea/dictionaries*
|
||||
*.ipr
|
||||
*.iws
|
||||
*.iml
|
||||
|
|
@ -33,7 +34,8 @@ local.properties
|
|||
|
||||
## NetBeans
|
||||
**/nbproject/private/
|
||||
build/
|
||||
/build/
|
||||
/app/build/
|
||||
nbbuild/
|
||||
dist/
|
||||
nbdist/
|
||||
|
|
@ -50,6 +52,3 @@ gradle-app.setting
|
|||
|
||||
## Android
|
||||
gen/
|
||||
|
||||
## Prebuilt
|
||||
Backup.apk
|
||||
|
|
|
|||
9
.idea/codeStyles/Project.xml
generated
9
.idea/codeStyles/Project.xml
generated
|
|
@ -4,15 +4,6 @@
|
|||
<option name="PACKAGES_TO_USE_STAR_IMPORTS">
|
||||
<value />
|
||||
</option>
|
||||
<option name="PACKAGES_IMPORT_LAYOUT">
|
||||
<value>
|
||||
<package name="" alias="false" withSubpackages="true" />
|
||||
<package name="java" alias="false" withSubpackages="true" />
|
||||
<package name="javax" alias="false" withSubpackages="true" />
|
||||
<package name="kotlin" alias="false" withSubpackages="true" />
|
||||
<package name="" alias="true" withSubpackages="true" />
|
||||
</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="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
|
||||
|
|
|
|||
14
.idea/dictionaries/user.xml
generated
Normal file
14
.idea/dictionaries/user.xml
generated
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
<component name="ProjectDictionaryState">
|
||||
<dictionary name="user">
|
||||
<words>
|
||||
<w>apk</w>
|
||||
<w>chunker</w>
|
||||
<w>ejectable</w>
|
||||
<w>hasher</w>
|
||||
<w>hkdf</w>
|
||||
<w>restorable</w>
|
||||
<w>seedvault</w>
|
||||
<w>snowden</w>
|
||||
</words>
|
||||
</dictionary>
|
||||
</component>
|
||||
1
.idea/runConfigurations.xml
generated
1
.idea/runConfigurations.xml
generated
|
|
@ -3,6 +3,7 @@
|
|||
<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" />
|
||||
|
|
|
|||
8
.idea/runConfigurations/All_unit_tests.xml
generated
Normal file
8
.idea/runConfigurations/All_unit_tests.xml
generated
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="All unit tests" type="CompoundRunConfigurationType">
|
||||
<toRun name="Unit tests: storage/lib" type="AndroidJUnit" />
|
||||
<toRun name="Unit tests: app" type="AndroidJUnit" />
|
||||
<toRun name="Unit tests: contactsbackup" type="AndroidJUnit" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
</component>
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="Instrumentation Tests" type="AndroidTestRunConfigurationType" factoryName="Android Instrumented Tests" singleton="true">
|
||||
<configuration default="false" name="Instrumentation tests: app" type="AndroidTestRunConfigurationType" factoryName="Android Instrumented Tests" singleton="true">
|
||||
<module name="seedvault.app" />
|
||||
<option name="TESTING_TYPE" value="0" />
|
||||
<option name="METHOD_NAME" value="" />
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="Unit Tests" type="AndroidJUnit" factoryName="Android JUnit">
|
||||
<configuration default="false" name="Unit tests: app" type="AndroidJUnit" factoryName="Android JUnit">
|
||||
<module name="seedvault.app" />
|
||||
<useClassPathOnly />
|
||||
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
|
||||
15
.idea/runConfigurations/Unit_tests__contactsbackup.xml
generated
Normal file
15
.idea/runConfigurations/Unit_tests__contactsbackup.xml
generated
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="Unit tests: contactsbackup" type="AndroidJUnit" factoryName="Android JUnit">
|
||||
<module name="seedvault.contactsbackup" />
|
||||
<useClassPathOnly />
|
||||
<option name="MAIN_CLASS_NAME" value="" />
|
||||
<option name="METHOD_NAME" value="" />
|
||||
<option name="TEST_OBJECT" value="directory" />
|
||||
<option name="PARAMETERS" value="" />
|
||||
<option name="WORKING_DIRECTORY" value="$MODULE_DIR$" />
|
||||
<dir value="$PROJECT_DIR$/contactsbackup/src/test/java" />
|
||||
<method v="2">
|
||||
<option name="Android.Gradle.BeforeRunTask" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
||||
15
.idea/runConfigurations/Unit_tests__storage_lib.xml
generated
Normal file
15
.idea/runConfigurations/Unit_tests__storage_lib.xml
generated
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="Unit tests: storage/lib" type="AndroidJUnit" factoryName="Android JUnit">
|
||||
<module name="seedvault.storage.lib" />
|
||||
<useClassPathOnly />
|
||||
<option name="MAIN_CLASS_NAME" value="" />
|
||||
<option name="METHOD_NAME" value="" />
|
||||
<option name="TEST_OBJECT" value="directory" />
|
||||
<option name="PARAMETERS" value="" />
|
||||
<option name="WORKING_DIRECTORY" value="$MODULE_DIR$" />
|
||||
<dir value="$PROJECT_DIR$/storage/lib/src/test/java" />
|
||||
<method v="2">
|
||||
<option name="Android.Gradle.BeforeRunTask" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
||||
21
.idea/runConfigurations/seedvault_storage_lib__assembleRelease_.xml
generated
Normal file
21
.idea/runConfigurations/seedvault_storage_lib__assembleRelease_.xml
generated
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="seedvault:storage:lib [assembleRelease]" type="GradleRunConfiguration" factoryName="Gradle">
|
||||
<ExternalSystemSettings>
|
||||
<option name="executionName" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$/storage/lib" />
|
||||
<option name="externalSystemIdString" value="GRADLE" />
|
||||
<option name="scriptParameters" value="" />
|
||||
<option name="taskDescriptions">
|
||||
<list />
|
||||
</option>
|
||||
<option name="taskNames">
|
||||
<list>
|
||||
<option value="assembleRelease" />
|
||||
</list>
|
||||
</option>
|
||||
<option name="vmOptions" value="" />
|
||||
</ExternalSystemSettings>
|
||||
<GradleScriptDebugEnabled>true</GradleScriptDebugEnabled>
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
</component>
|
||||
|
|
@ -31,10 +31,17 @@ android_app {
|
|||
"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",
|
||||
// koin
|
||||
"seedvault-lib-koin-core", // did not manage to add this as transitive dependency
|
||||
"seedvault-lib-koin-android",
|
||||
"seedvault-lib-koin-androidx-viewmodel",
|
||||
"seedvault-lib-novacrypto-bip39",
|
||||
// bip39
|
||||
"seedvault-lib-kotlin-bip39",
|
||||
],
|
||||
manifest: "app/src/main/AndroidManifest.xml",
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,12 @@
|
|||
|
||||
A backup application for the [Android Open Source Project](https://source.android.com/).
|
||||
|
||||
## Components
|
||||
|
||||
* [Local Contacts Backup](contactsbackup) - an app that backs up local on-device contacts
|
||||
* [Storage library](storage) - a library handling efficient backup of files
|
||||
* [Seedvault app](app) - the main app where all functionality comes together
|
||||
|
||||
## Features
|
||||
- Backup application data to a flash drive.
|
||||
- Restore application data from a flash drive.
|
||||
|
|
@ -30,6 +36,9 @@ It uses the same internal APIs as `adb backup` which is deprecated and thus need
|
|||
* `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.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.MANAGE_DOCUMENTS` to retrieve the available storage roots (optional) for better UX.
|
||||
|
||||
## Contributing
|
||||
|
|
|
|||
|
|
@ -16,13 +16,12 @@ def gitDescribe = { ->
|
|||
}
|
||||
|
||||
android {
|
||||
|
||||
compileSdkVersion 30
|
||||
buildToolsVersion '30.0.2'
|
||||
compileSdkVersion rootProject.ext.compileSdkVersion
|
||||
buildToolsVersion rootProject.ext.buildToolsVersion
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion 29 // leave at 29 for robolectric tests
|
||||
targetSdkVersion 30
|
||||
targetSdkVersion rootProject.ext.targetSdkVersion
|
||||
versionNameSuffix "-$gitDescribe"
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
testInstrumentationRunnerArguments disableAnalytics: 'true'
|
||||
|
|
@ -44,6 +43,7 @@ android {
|
|||
}
|
||||
kotlinOptions {
|
||||
jvmTarget = JavaVersion.VERSION_1_8.toString()
|
||||
languageVersion = "1.3"
|
||||
}
|
||||
testOptions {
|
||||
unitTests.all {
|
||||
|
|
@ -81,19 +81,75 @@ android {
|
|||
buildTypes.debug.signingConfig = signingConfigs.aosp
|
||||
}
|
||||
|
||||
apply from: '../gradle/dependencies.gradle'
|
||||
dependencies {
|
||||
compileOnly rootProject.ext.aosp_libs
|
||||
|
||||
ktlint {
|
||||
version = "0.36.0" // https://github.com/pinterest/ktlint/issues/764
|
||||
android = true
|
||||
enableExperimentalRules = false
|
||||
verbose = true
|
||||
disabledRules = [
|
||||
"import-ordering",
|
||||
"no-blank-line-before-rbrace",
|
||||
]
|
||||
/**
|
||||
* 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 "io.mockk:mockk:$mockk_version"
|
||||
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) {
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
package="com.stevesoltys.seedvault"
|
||||
android:versionCode="30000011"
|
||||
android:versionName="11-1.1">
|
||||
android:versionCode="30000211"
|
||||
android:versionName="11-2.1">
|
||||
<!--
|
||||
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.
|
||||
|
|
@ -113,5 +113,24 @@
|
|||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<!-- 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 -->
|
||||
<service
|
||||
android:name=".storage.StorageBackupService"
|
||||
android:exported="false"
|
||||
android:foregroundServiceType="dataSync"
|
||||
android:label="BackupService" />
|
||||
<!-- Does restore as a foreground service -->
|
||||
<service
|
||||
android:name=".storage.StorageRestoreService"
|
||||
android:exported="false"
|
||||
android:foregroundServiceType="dataSync"
|
||||
android:label="RestoreService" />
|
||||
|
||||
</application>
|
||||
</manifest>
|
||||
|
|
|
|||
|
|
@ -17,8 +17,10 @@ import com.stevesoltys.seedvault.restore.install.installModule
|
|||
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.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
|
||||
|
|
@ -43,11 +45,12 @@ open class App : Application() {
|
|||
factory<IBackupManager> { IBackupManager.Stub.asInterface(getService(BACKUP_SERVICE)) }
|
||||
factory { AppListRetriever(this@App, get(), get(), get()) }
|
||||
|
||||
viewModel { SettingsViewModel(this@App, get(), get(), get(), get(), get()) }
|
||||
viewModel { RecoveryCodeViewModel(this@App, get(), get(), get()) }
|
||||
viewModel { BackupStorageViewModel(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()) }
|
||||
viewModel { RestoreViewModel(this@App, get(), get(), get(), get(), get(), get()) }
|
||||
viewModel { FileSelectionViewModel(this@App, get()) }
|
||||
}
|
||||
|
||||
override fun onCreate() {
|
||||
|
|
@ -85,6 +88,7 @@ open class App : Application() {
|
|||
backupModule,
|
||||
restoreModule,
|
||||
installModule,
|
||||
storageModule,
|
||||
appModule
|
||||
)
|
||||
)
|
||||
|
|
|
|||
|
|
@ -14,9 +14,12 @@ 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
|
||||
|
|
@ -54,9 +57,16 @@ class UsbIntentReceiver : UsbMonitor() {
|
|||
}
|
||||
|
||||
override fun onStatusChanged(context: Context, action: String, device: UsbDevice) {
|
||||
Thread {
|
||||
requestBackup(context)
|
||||
}.start()
|
||||
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()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,11 +44,6 @@ internal class DocumentsProviderBackupPlugin(
|
|||
storage.currentFullBackupDir ?: throw IOException()
|
||||
}
|
||||
|
||||
@Throws(IOException::class)
|
||||
override suspend fun deleteAllBackups() {
|
||||
storage.rootBackupDir?.deleteContents(context)
|
||||
}
|
||||
|
||||
@Throws(IOException::class)
|
||||
override suspend fun getMetadataOutputStream(): OutputStream {
|
||||
val setDir = storage.getSetDir() ?: throw IOException()
|
||||
|
|
|
|||
|
|
@ -24,6 +24,9 @@ internal class DocumentsProviderRestorePlugin(
|
|||
override val fullRestorePlugin: FullRestorePlugin
|
||||
) : RestorePlugin {
|
||||
|
||||
private val tokenRegex = Regex("([0-9]{13})") // good until the year 2286
|
||||
private val chunkFolderRegex = Regex("[a-f0-9]{2}")
|
||||
|
||||
@Throws(IOException::class)
|
||||
override suspend fun hasBackup(uri: Uri): Boolean {
|
||||
val parent = DocumentFile.fromTreeUri(context, uri) ?: throw AssertionError()
|
||||
|
|
@ -59,18 +62,21 @@ internal class DocumentsProviderRestorePlugin(
|
|||
return backupSets
|
||||
}
|
||||
for (set in files) {
|
||||
// retrieve name only once as this causes a DB query
|
||||
val name = set.name
|
||||
|
||||
// get current token from set or continue to next file/set
|
||||
val token = set.getTokenOrNull() ?: continue
|
||||
val token = set.getTokenOrNull(name) ?: continue
|
||||
|
||||
// block until children of set are available
|
||||
val metadata = try {
|
||||
set.findFileBlocking(context, FILE_BACKUP_METADATA)
|
||||
} catch (e: IOException) {
|
||||
Log.e(TAG, "Error reading metadata file in backup set folder: ${set.name}", e)
|
||||
Log.e(TAG, "Error reading metadata file in backup set folder: $name", e)
|
||||
null
|
||||
}
|
||||
if (metadata == null) {
|
||||
Log.w(TAG, "Missing metadata file in backup set folder: ${set.name}")
|
||||
Log.w(TAG, "Missing metadata file in backup set folder: $name")
|
||||
} else {
|
||||
backupSets.add(BackupSet(token, metadata))
|
||||
}
|
||||
|
|
@ -78,21 +84,29 @@ internal class DocumentsProviderRestorePlugin(
|
|||
return backupSets
|
||||
}
|
||||
|
||||
private fun DocumentFile.getTokenOrNull(): Long? {
|
||||
if (!isDirectory || name == null) {
|
||||
if (name != FILE_NO_MEDIA) {
|
||||
private fun DocumentFile.getTokenOrNull(name: String?): Long? {
|
||||
val looksLikeToken = name != null && tokenRegex.matches(name)
|
||||
// check for isDirectory only if we already have a valid token (causes DB query)
|
||||
if (!looksLikeToken || !isDirectory) {
|
||||
// only log unexpected output
|
||||
if (name != null && isUnexpectedFile(name)) {
|
||||
Log.w(TAG, "Found invalid backup set folder: $name")
|
||||
}
|
||||
return null
|
||||
}
|
||||
return try {
|
||||
name!!.toLong()
|
||||
name?.toLong()
|
||||
} catch (e: NumberFormatException) {
|
||||
Log.w(TAG, "Found invalid backup set folder: $name")
|
||||
null
|
||||
throw AssertionError(e)
|
||||
}
|
||||
}
|
||||
|
||||
private fun isUnexpectedFile(name: String): Boolean {
|
||||
return name != FILE_NO_MEDIA &&
|
||||
!chunkFolderRegex.matches(name) &&
|
||||
!name.endsWith(".SeedSnap")
|
||||
}
|
||||
|
||||
@Throws(IOException::class)
|
||||
override suspend fun getApkInputStream(
|
||||
token: Long,
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ import androidx.annotation.CallSuper
|
|||
import com.stevesoltys.seedvault.R
|
||||
import com.stevesoltys.seedvault.restore.DisplayFragment.RESTORE_APPS
|
||||
import com.stevesoltys.seedvault.restore.DisplayFragment.RESTORE_BACKUP
|
||||
import com.stevesoltys.seedvault.restore.DisplayFragment.RESTORE_FILES
|
||||
import com.stevesoltys.seedvault.restore.DisplayFragment.RESTORE_FILES_STARTED
|
||||
import com.stevesoltys.seedvault.restore.install.InstallProgressFragment
|
||||
import com.stevesoltys.seedvault.ui.LiveEventHandler
|
||||
import com.stevesoltys.seedvault.ui.RequireProvisioningActivity
|
||||
|
|
@ -28,6 +30,8 @@ class RestoreActivity : RequireProvisioningActivity() {
|
|||
when (fragment) {
|
||||
RESTORE_APPS -> showFragment(InstallProgressFragment())
|
||||
RESTORE_BACKUP -> showFragment(RestoreProgressFragment())
|
||||
RESTORE_FILES -> showFragment(RestoreFilesFragment())
|
||||
RESTORE_FILES_STARTED -> showFragment(RestoreFilesStartedFragment())
|
||||
else -> throw AssertionError()
|
||||
}
|
||||
})
|
||||
|
|
|
|||
|
|
@ -0,0 +1,66 @@
|
|||
package com.stevesoltys.seedvault.restore
|
||||
|
||||
import android.app.Activity.RESULT_OK
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.ViewStub
|
||||
import android.widget.Button
|
||||
import android.widget.TextView
|
||||
import androidx.fragment.app.Fragment
|
||||
import com.stevesoltys.seedvault.R
|
||||
import org.calyxos.backup.storage.api.SnapshotItem
|
||||
import org.calyxos.backup.storage.ui.restore.SnapshotFragment
|
||||
import org.koin.androidx.viewmodel.ext.android.sharedViewModel
|
||||
|
||||
internal class RestoreFilesFragment : SnapshotFragment() {
|
||||
override val viewModel: RestoreViewModel by sharedViewModel()
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View {
|
||||
val v = super.onCreateView(inflater, container, savedInstanceState)
|
||||
|
||||
val topStub: ViewStub = v.findViewById(R.id.topStub)
|
||||
topStub.layoutResource = R.layout.header_snapshots
|
||||
topStub.inflate()
|
||||
|
||||
val bottomStub: ViewStub = v.findViewById(R.id.bottomStub)
|
||||
bottomStub.layoutResource = R.layout.footer_snapshots
|
||||
val footer = bottomStub.inflate()
|
||||
val skipView: TextView = footer.findViewById(R.id.skipView)
|
||||
skipView.setOnClickListener {
|
||||
requireActivity().apply {
|
||||
setResult(RESULT_OK)
|
||||
finishAfterTransition()
|
||||
}
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
override fun onSnapshotClicked(item: SnapshotItem) {
|
||||
viewModel.startFilesRestore(item)
|
||||
}
|
||||
}
|
||||
|
||||
internal class RestoreFilesStartedFragment : Fragment() {
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View {
|
||||
val v: View = inflater.inflate(R.layout.fragment_restore_files_started, container, false)
|
||||
|
||||
val button: Button = v.findViewById(R.id.button)
|
||||
button.setOnClickListener {
|
||||
requireActivity().apply {
|
||||
setResult(RESULT_OK)
|
||||
finishAfterTransition()
|
||||
}
|
||||
}
|
||||
return v
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,5 @@
|
|||
package com.stevesoltys.seedvault.restore
|
||||
|
||||
import android.app.Activity.RESULT_OK
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
|
|
@ -38,7 +37,7 @@ class RestoreProgressFragment : Fragment() {
|
|||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
): View {
|
||||
val v: View = inflater.inflate(R.layout.fragment_restore_progress, container, false)
|
||||
|
||||
progressBar = v.findViewById(R.id.progressBar)
|
||||
|
|
@ -61,8 +60,7 @@ class RestoreProgressFragment : Fragment() {
|
|||
|
||||
button.setText(R.string.restore_finished_button)
|
||||
button.setOnClickListener {
|
||||
requireActivity().setResult(RESULT_OK)
|
||||
requireActivity().finishAfterTransition()
|
||||
viewModel.onFinishClickedAfterRestoringAppData()
|
||||
}
|
||||
|
||||
// decryption will fail when the device is locked, so keep the screen on to prevent locking
|
||||
|
|
|
|||
|
|
@ -22,19 +22,19 @@ class RestoreSetFragment : Fragment() {
|
|||
private lateinit var listView: RecyclerView
|
||||
private lateinit var progressBar: ProgressBar
|
||||
private lateinit var errorView: TextView
|
||||
private lateinit var backView: TextView
|
||||
private lateinit var skipView: TextView
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
): View {
|
||||
val v: View = inflater.inflate(R.layout.fragment_restore_set, container, false)
|
||||
|
||||
listView = v.findViewById(R.id.listView)
|
||||
progressBar = v.findViewById(R.id.progressBar)
|
||||
errorView = v.findViewById(R.id.errorView)
|
||||
backView = v.findViewById(R.id.backView)
|
||||
skipView = v.findViewById(R.id.skipView)
|
||||
|
||||
return v
|
||||
}
|
||||
|
|
@ -49,7 +49,9 @@ class RestoreSetFragment : Fragment() {
|
|||
onRestoreResultsLoaded(result)
|
||||
})
|
||||
|
||||
backView.setOnClickListener { requireActivity().finishAfterTransition() }
|
||||
skipView.setOnClickListener {
|
||||
viewModel.onFinishClickedAfterRestoringAppData()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
|
|
|
|||
|
|
@ -5,9 +5,11 @@ import android.app.backup.IBackupManager
|
|||
import android.app.backup.IRestoreObserver
|
||||
import android.app.backup.IRestoreSession
|
||||
import android.app.backup.RestoreSet
|
||||
import android.content.Intent
|
||||
import android.os.RemoteException
|
||||
import android.os.UserHandle
|
||||
import android.util.Log
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.annotation.WorkerThread
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
|
|
@ -27,11 +29,14 @@ import com.stevesoltys.seedvault.metadata.PackageState.UNKNOWN_ERROR
|
|||
import com.stevesoltys.seedvault.metadata.PackageState.WAS_STOPPED
|
||||
import com.stevesoltys.seedvault.restore.DisplayFragment.RESTORE_APPS
|
||||
import com.stevesoltys.seedvault.restore.DisplayFragment.RESTORE_BACKUP
|
||||
import com.stevesoltys.seedvault.restore.DisplayFragment.RESTORE_FILES
|
||||
import com.stevesoltys.seedvault.restore.DisplayFragment.RESTORE_FILES_STARTED
|
||||
import com.stevesoltys.seedvault.restore.install.ApkRestore
|
||||
import com.stevesoltys.seedvault.restore.install.InstallIntentCreator
|
||||
import com.stevesoltys.seedvault.restore.install.InstallResult
|
||||
import com.stevesoltys.seedvault.restore.install.isInstalled
|
||||
import com.stevesoltys.seedvault.settings.SettingsManager
|
||||
import com.stevesoltys.seedvault.storage.StorageRestoreService
|
||||
import com.stevesoltys.seedvault.transport.TRANSPORT_ID
|
||||
import com.stevesoltys.seedvault.transport.restore.RestoreCoordinator
|
||||
import com.stevesoltys.seedvault.ui.AppBackupState
|
||||
|
|
@ -54,6 +59,11 @@ import kotlinx.coroutines.flow.flowOn
|
|||
import kotlinx.coroutines.flow.onCompletion
|
||||
import kotlinx.coroutines.flow.onStart
|
||||
import kotlinx.coroutines.launch
|
||||
import org.calyxos.backup.storage.api.SnapshotItem
|
||||
import org.calyxos.backup.storage.api.StorageBackup
|
||||
import org.calyxos.backup.storage.restore.RestoreService.Companion.EXTRA_TIMESTAMP_START
|
||||
import org.calyxos.backup.storage.restore.RestoreService.Companion.EXTRA_USER_ID
|
||||
import org.calyxos.backup.storage.ui.restore.SnapshotViewModel
|
||||
import java.util.LinkedList
|
||||
import kotlin.coroutines.Continuation
|
||||
import kotlin.coroutines.resume
|
||||
|
|
@ -68,8 +78,10 @@ internal class RestoreViewModel(
|
|||
private val backupManager: IBackupManager,
|
||||
private val restoreCoordinator: RestoreCoordinator,
|
||||
private val apkRestore: ApkRestore,
|
||||
storageBackup: StorageBackup,
|
||||
private val ioDispatcher: CoroutineDispatcher = Dispatchers.IO
|
||||
) : RequireProvisioningViewModel(app, settingsManager, keyManager), RestorableBackupClickListener {
|
||||
) : RequireProvisioningViewModel(app, settingsManager, keyManager),
|
||||
RestorableBackupClickListener, SnapshotViewModel {
|
||||
|
||||
override val isRestoreOperation = true
|
||||
|
||||
|
|
@ -110,6 +122,8 @@ internal class RestoreViewModel(
|
|||
private val mRestoreBackupResult = MutableLiveData<RestoreBackupResult>()
|
||||
internal val restoreBackupResult: LiveData<RestoreBackupResult> get() = mRestoreBackupResult
|
||||
|
||||
override val snapshots = storageBackup.getBackupSnapshots().asLiveData(ioDispatcher)
|
||||
|
||||
@Throws(RemoteException::class)
|
||||
private fun getOrStartSession(): IRestoreSession {
|
||||
val session = this.session
|
||||
|
|
@ -168,7 +182,7 @@ internal class RestoreViewModel(
|
|||
.asLiveData(ioDispatcher)
|
||||
}
|
||||
|
||||
internal fun onNextClicked() {
|
||||
internal fun onNextClickedAfterInstallingApps() {
|
||||
mDisplayFragment.postEvent(RESTORE_BACKUP)
|
||||
val token = mChosenRestorableBackup.value?.token ?: throw AssertionError()
|
||||
viewModelScope.launch(ioDispatcher) {
|
||||
|
|
@ -371,6 +385,20 @@ internal class RestoreViewModel(
|
|||
|
||||
}
|
||||
|
||||
@UiThread
|
||||
internal fun onFinishClickedAfterRestoringAppData() {
|
||||
mDisplayFragment.setEvent(RESTORE_FILES)
|
||||
}
|
||||
|
||||
@UiThread
|
||||
internal fun startFilesRestore(item: SnapshotItem) {
|
||||
val i = Intent(app, StorageRestoreService::class.java)
|
||||
i.putExtra(EXTRA_USER_ID, item.storedSnapshot.userId)
|
||||
i.putExtra(EXTRA_TIMESTAMP_START, item.time)
|
||||
app.startForegroundService(i)
|
||||
mDisplayFragment.setEvent(RESTORE_FILES_STARTED)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
internal class RestoreSetResult(
|
||||
|
|
@ -389,4 +417,6 @@ internal class RestoreBackupResult(val errorMsg: String? = null) {
|
|||
internal fun hasError(): Boolean = errorMsg != null
|
||||
}
|
||||
|
||||
internal enum class DisplayFragment { RESTORE_APPS, RESTORE_BACKUP }
|
||||
internal enum class DisplayFragment {
|
||||
RESTORE_APPS, RESTORE_BACKUP, RESTORE_FILES, RESTORE_FILES_STARTED
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ class InstallProgressFragment : Fragment(), InstallItemListener {
|
|||
addItemDecoration(DividerItemDecoration(context, VERTICAL))
|
||||
}
|
||||
button.setText(R.string.restore_next)
|
||||
button.setOnClickListener { viewModel.onNextClicked() }
|
||||
button.setOnClickListener { viewModel.onNextClickedAfterInstallingApps() }
|
||||
|
||||
viewModel.chosenRestorableBackup.observe(viewLifecycleOwner, Observer { restorableBackup ->
|
||||
backupNameView.text = restorableBackup.name
|
||||
|
|
@ -76,7 +76,7 @@ class InstallProgressFragment : Fragment(), InstallItemListener {
|
|||
|
||||
private fun onInstallResult(installResult: InstallResult) {
|
||||
// skip this screen, if there are no apps to install
|
||||
if (installResult.isEmpty) viewModel.onNextClicked()
|
||||
if (installResult.isEmpty) viewModel.onNextClickedAfterInstallingApps()
|
||||
|
||||
// if finished, treat all still queued apps as failed and resort/redisplay adapter items
|
||||
if (installResult.isFinished) {
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ class AppStatusFragment : Fragment(), AppStatusToggleListener {
|
|||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
): View {
|
||||
setHasOptionsMenu(true)
|
||||
val v: View = inflater.inflate(R.layout.fragment_app_status, container, false)
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import android.content.Intent
|
|||
import android.os.Bundle
|
||||
import android.os.RemoteException
|
||||
import android.provider.Settings
|
||||
import android.provider.Settings.Secure.BACKUP_AUTO_RESTORE // ktlint-disable no-unused-imports
|
||||
import android.provider.Settings.Secure.BACKUP_AUTO_RESTORE
|
||||
import android.util.Log
|
||||
import android.view.Menu
|
||||
import android.view.MenuInflater
|
||||
|
|
@ -37,6 +37,8 @@ class SettingsFragment : PreferenceFragmentCompat() {
|
|||
private lateinit var apkBackup: TwoStatePreference
|
||||
private lateinit var backupLocation: Preference
|
||||
private lateinit var backupStatus: Preference
|
||||
private lateinit var backupStorage: TwoStatePreference
|
||||
private lateinit var backupRecoveryCode: Preference
|
||||
|
||||
private var menuBackupNow: MenuItem? = null
|
||||
private var menuRestore: MenuItem? = null
|
||||
|
|
@ -101,6 +103,19 @@ class SettingsFragment : PreferenceFragmentCompat() {
|
|||
return@OnPreferenceChangeListener false
|
||||
}
|
||||
backupStatus = findPreference("backup_status")!!
|
||||
|
||||
backupStorage = findPreference("backup_storage")!!
|
||||
backupStorage.onPreferenceChangeListener = OnPreferenceChangeListener { _, newValue ->
|
||||
val disable = !(newValue as Boolean)
|
||||
if (disable) {
|
||||
viewModel.disableStorageBackup()
|
||||
return@OnPreferenceChangeListener true
|
||||
}
|
||||
onEnablingStorageBackup()
|
||||
return@OnPreferenceChangeListener false
|
||||
}
|
||||
|
||||
backupRecoveryCode = findPreference("backup_recovery_code")!!
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
|
|
@ -109,6 +124,11 @@ class SettingsFragment : PreferenceFragmentCompat() {
|
|||
viewModel.lastBackupTime.observe(viewLifecycleOwner, Observer { time ->
|
||||
setAppBackupStatusSummary(time)
|
||||
})
|
||||
|
||||
val backupFiles: Preference = findPreference("backup_files")!!
|
||||
viewModel.filesSummary.observe(viewLifecycleOwner, Observer { summary ->
|
||||
backupFiles.summary = summary
|
||||
})
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
|
|
@ -189,4 +209,40 @@ class SettingsFragment : PreferenceFragmentCompat() {
|
|||
backupStatus.summary = getString(R.string.settings_backup_status_summary, lastBackup)
|
||||
}
|
||||
|
||||
private fun onEnablingStorageBackup() {
|
||||
AlertDialog.Builder(requireContext())
|
||||
.setIcon(R.drawable.ic_warning)
|
||||
.setTitle(R.string.settings_backup_storage_dialog_title)
|
||||
.setMessage(R.string.settings_backup_storage_dialog_message)
|
||||
.setPositiveButton(R.string.settings_backup_storage_dialog_ok) { dialog, _ ->
|
||||
if (viewModel.hasMainKey()) {
|
||||
viewModel.enableStorageBackup()
|
||||
backupStorage.isChecked = true
|
||||
} else {
|
||||
showCodeVerificationNeededDialog()
|
||||
}
|
||||
dialog.dismiss()
|
||||
}
|
||||
.setNegativeButton(R.string.settings_backup_apk_dialog_cancel) { dialog, _ ->
|
||||
dialog.dismiss()
|
||||
}
|
||||
.show()
|
||||
}
|
||||
|
||||
private fun showCodeVerificationNeededDialog() {
|
||||
AlertDialog.Builder(requireContext())
|
||||
.setIcon(R.drawable.ic_vpn_key)
|
||||
.setTitle(R.string.settings_backup_storage_code_dialog_title)
|
||||
.setMessage(R.string.settings_backup_storage_code_dialog_message)
|
||||
.setPositiveButton(R.string.settings_backup_storage_code_dialog_ok) { dialog, _ ->
|
||||
val callback = (requireActivity() as OnPreferenceStartFragmentCallback)
|
||||
callback.onPreferenceStartFragment(this, backupRecoveryCode)
|
||||
dialog.dismiss()
|
||||
}
|
||||
.setNegativeButton(R.string.settings_backup_apk_dialog_cancel) { dialog, _ ->
|
||||
dialog.dismiss()
|
||||
}
|
||||
.show()
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,6 +30,8 @@ private const val PREF_KEY_FLASH_DRIVE_PRODUCT_ID = "flashDriveProductId"
|
|||
|
||||
private const val PREF_KEY_BACKUP_APP_BLACKLIST = "backupAppBlacklist"
|
||||
|
||||
private const val PREF_KEY_BACKUP_STORAGE = "backup_storage"
|
||||
|
||||
class SettingsManager(private val context: Context) {
|
||||
|
||||
private val prefs = permitDiskReads {
|
||||
|
|
@ -138,6 +140,8 @@ class SettingsManager(private val context: Context) {
|
|||
|
||||
fun isBackupEnabled(packageName: String) = !blacklistedApps.contains(packageName)
|
||||
|
||||
fun isStorageBackupEnabled() = prefs.getBoolean(PREF_KEY_BACKUP_STORAGE, false)
|
||||
|
||||
@UiThread
|
||||
fun onAppBackupStatusChanged(status: AppStatus) {
|
||||
if (status.enabled) blacklistedApps.remove(status.packageName)
|
||||
|
|
@ -171,13 +175,14 @@ data class Storage(
|
|||
* but it isn't available right now.
|
||||
*/
|
||||
fun isUnavailableNetwork(context: Context): Boolean {
|
||||
return requiresNetwork && !hasInternet(context)
|
||||
return requiresNetwork && !hasUnmeteredInternet(context)
|
||||
}
|
||||
|
||||
private fun hasInternet(context: Context): Boolean {
|
||||
private fun hasUnmeteredInternet(context: Context): Boolean {
|
||||
val cm = context.getSystemService(ConnectivityManager::class.java)
|
||||
val isMetered = cm.isActiveNetworkMetered()
|
||||
val capabilities = cm.getNetworkCapabilities(cm.activeNetwork) ?: return false
|
||||
return capabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
|
||||
return capabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET) && !isMetered
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
package com.stevesoltys.seedvault.settings
|
||||
|
||||
import android.app.Application
|
||||
import android.app.job.JobInfo.NETWORK_TYPE_NONE
|
||||
import android.app.job.JobInfo.NETWORK_TYPE_UNMETERED
|
||||
import android.content.Intent
|
||||
import android.database.ContentObserver
|
||||
import android.net.ConnectivityManager
|
||||
import android.net.Network
|
||||
|
|
@ -12,6 +15,7 @@ import android.util.Log
|
|||
import android.widget.Toast
|
||||
import android.widget.Toast.LENGTH_LONG
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.core.content.ContextCompat.startForegroundService
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.Transformations.switchMap
|
||||
|
|
@ -22,11 +26,17 @@ import com.stevesoltys.seedvault.R
|
|||
import com.stevesoltys.seedvault.crypto.KeyManager
|
||||
import com.stevesoltys.seedvault.metadata.MetadataManager
|
||||
import com.stevesoltys.seedvault.permitDiskReads
|
||||
import com.stevesoltys.seedvault.storage.StorageBackupJobService
|
||||
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.RequireProvisioningViewModel
|
||||
import com.stevesoltys.seedvault.ui.notification.BackupNotificationManager
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import org.calyxos.backup.storage.api.StorageBackup
|
||||
import org.calyxos.backup.storage.backup.BackupJobService
|
||||
import java.util.concurrent.TimeUnit.HOURS
|
||||
|
||||
private const val TAG = "SettingsViewModel"
|
||||
private const val USER_FULL_DATA_BACKUP_AWARE = "user_full_data_backup_aware"
|
||||
|
|
@ -37,7 +47,8 @@ internal class SettingsViewModel(
|
|||
keyManager: KeyManager,
|
||||
private val notificationManager: BackupNotificationManager,
|
||||
private val metadataManager: MetadataManager,
|
||||
private val appListRetriever: AppListRetriever
|
||||
private val appListRetriever: AppListRetriever,
|
||||
private val storageBackup: StorageBackup
|
||||
) : RequireProvisioningViewModel(app, settingsManager, keyManager) {
|
||||
|
||||
private val contentResolver = app.contentResolver
|
||||
|
|
@ -59,6 +70,9 @@ internal class SettingsViewModel(
|
|||
private val mAppEditMode = MutableLiveData<Boolean>()
|
||||
internal val appEditMode: LiveData<Boolean> = mAppEditMode
|
||||
|
||||
private val _filesSummary = MutableLiveData<String>()
|
||||
internal val filesSummary: LiveData<String> = _filesSummary
|
||||
|
||||
private val storageObserver = object : ContentObserver(null) {
|
||||
override fun onChange(selfChange: Boolean, uris: MutableCollection<Uri>, flags: Int) {
|
||||
onStorageLocationChanged()
|
||||
|
|
@ -89,6 +103,7 @@ internal class SettingsViewModel(
|
|||
metadataManager.getLastBackupTime()
|
||||
}
|
||||
onStorageLocationChanged()
|
||||
loadFilesSummary()
|
||||
}
|
||||
|
||||
override fun onStorageLocationChanged() {
|
||||
|
|
@ -116,6 +131,14 @@ internal class SettingsViewModel(
|
|||
networkCallback.registered = true
|
||||
}
|
||||
|
||||
if (settingsManager.isStorageBackupEnabled()) {
|
||||
// disable storage backup if new storage is on USB
|
||||
if (storage.isUsb) disableStorageBackup()
|
||||
// enable it, just in case the previous storage was on USB,
|
||||
// also to update the network requirement of the new storage
|
||||
else enableStorageBackup()
|
||||
}
|
||||
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
val canDo = settingsManager.canDoBackupNow()
|
||||
mBackupPossible.postValue(canDo)
|
||||
|
|
@ -134,8 +157,15 @@ internal class SettingsViewModel(
|
|||
// maybe replace the check below with one that checks if our transport service is running
|
||||
if (notificationManager.hasActiveBackupNotifications()) {
|
||||
Toast.makeText(app, R.string.notification_backup_already_running, LENGTH_LONG).show()
|
||||
} else {
|
||||
Thread { requestBackup(app) }.start()
|
||||
} else viewModelScope.launch(Dispatchers.IO) {
|
||||
if (settingsManager.isStorageBackupEnabled()) {
|
||||
val i = Intent(app, StorageBackupService::class.java)
|
||||
// this starts an app backup afterwards
|
||||
i.putExtra(EXTRA_START_APP_BACKUP, true)
|
||||
startForegroundService(app, i)
|
||||
} else {
|
||||
requestBackup(app)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -156,6 +186,14 @@ internal class SettingsViewModel(
|
|||
settingsManager.onAppBackupStatusChanged(status)
|
||||
}
|
||||
|
||||
@UiThread
|
||||
fun loadFilesSummary() = viewModelScope.launch {
|
||||
val uriSummary = storageBackup.getUriSummaryString()
|
||||
_filesSummary.value = if (uriSummary.isEmpty()) {
|
||||
app.getString(R.string.settings_backup_files_summary)
|
||||
} else uriSummary
|
||||
}
|
||||
|
||||
/**
|
||||
* Disables AOSP's call log backup
|
||||
*
|
||||
|
|
@ -170,4 +208,25 @@ internal class SettingsViewModel(
|
|||
}
|
||||
}
|
||||
|
||||
fun hasMainKey(): Boolean {
|
||||
return keyManager.hasMainKey()
|
||||
}
|
||||
|
||||
fun enableStorageBackup() {
|
||||
val storage = settingsManager.getStorage() ?: error("no storage available")
|
||||
if (!storage.isUsb) BackupJobService.scheduleJob(
|
||||
context = app,
|
||||
jobServiceClass = StorageBackupJobService::class.java,
|
||||
periodMillis = HOURS.toMillis(24),
|
||||
networkType = if (storage.requiresNetwork) NETWORK_TYPE_UNMETERED
|
||||
else NETWORK_TYPE_NONE,
|
||||
deviceIdle = false,
|
||||
charging = true
|
||||
)
|
||||
}
|
||||
|
||||
fun disableStorageBackup() {
|
||||
BackupJobService.cancelJob(app)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,20 @@
|
|||
package com.stevesoltys.seedvault.storage
|
||||
|
||||
import android.content.Context
|
||||
import androidx.documentfile.provider.DocumentFile
|
||||
import com.stevesoltys.seedvault.crypto.KeyManager
|
||||
import com.stevesoltys.seedvault.plugins.saf.DocumentsStorage
|
||||
import org.calyxos.backup.storage.plugin.saf.SafStoragePlugin
|
||||
import javax.crypto.SecretKey
|
||||
|
||||
internal class SeedvaultStoragePlugin(
|
||||
context: Context,
|
||||
private val storage: DocumentsStorage,
|
||||
private val keyManager: KeyManager
|
||||
) : SafStoragePlugin(context) {
|
||||
override val root: DocumentFile
|
||||
get() = storage.rootBackupDir ?: error("No storage set")
|
||||
|
||||
override fun getMasterKey(): SecretKey = keyManager.getMainKey()
|
||||
override fun hasMasterKey(): Boolean = keyManager.hasMainKey()
|
||||
}
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
package com.stevesoltys.seedvault.storage
|
||||
|
||||
import android.content.Intent
|
||||
import com.stevesoltys.seedvault.transport.requestBackup
|
||||
import org.calyxos.backup.storage.api.BackupObserver
|
||||
import org.calyxos.backup.storage.api.RestoreObserver
|
||||
import org.calyxos.backup.storage.api.StorageBackup
|
||||
import org.calyxos.backup.storage.backup.BackupJobService
|
||||
import org.calyxos.backup.storage.backup.BackupService
|
||||
import org.calyxos.backup.storage.backup.NotificationBackupObserver
|
||||
import org.calyxos.backup.storage.restore.NotificationRestoreObserver
|
||||
import org.calyxos.backup.storage.restore.RestoreService
|
||||
import org.koin.android.ext.android.inject
|
||||
|
||||
/*
|
||||
test and debug with
|
||||
|
||||
adb shell dumpsys jobscheduler |
|
||||
grep -A 23 -B 4 "Service: com.stevesoltys.seedvault/.storage.StorageBackupJobService"
|
||||
|
||||
force running with:
|
||||
|
||||
adb shell cmd jobscheduler run -f com.stevesoltys.seedvault 0
|
||||
|
||||
*/
|
||||
internal class StorageBackupJobService : BackupJobService(StorageBackupService::class.java)
|
||||
|
||||
internal class StorageBackupService : BackupService() {
|
||||
|
||||
companion object {
|
||||
internal const val EXTRA_START_APP_BACKUP = "startAppBackup"
|
||||
}
|
||||
|
||||
override val storageBackup: StorageBackup by inject()
|
||||
|
||||
// use lazy delegate because context isn't available during construction time
|
||||
override val backupObserver: BackupObserver by lazy {
|
||||
NotificationBackupObserver(applicationContext)
|
||||
}
|
||||
|
||||
override fun onBackupFinished(intent: Intent, success: Boolean) {
|
||||
if (intent.getBooleanExtra(EXTRA_START_APP_BACKUP, false)) {
|
||||
requestBackup(applicationContext)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal class StorageRestoreService : RestoreService() {
|
||||
override val storageBackup: StorageBackup by inject()
|
||||
|
||||
// use lazy delegate because context isn't available during construction time
|
||||
override val restoreObserver: RestoreObserver by lazy {
|
||||
NotificationRestoreObserver(applicationContext)
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
package com.stevesoltys.seedvault.storage
|
||||
|
||||
import org.calyxos.backup.storage.api.StorageBackup
|
||||
import org.calyxos.backup.storage.api.StoragePlugin
|
||||
import org.koin.dsl.module
|
||||
|
||||
val storageModule = module {
|
||||
single<StoragePlugin> { SeedvaultStoragePlugin(get(), get(), get()) }
|
||||
single { StorageBackup(get(), get()) }
|
||||
}
|
||||
|
|
@ -2,10 +2,8 @@ package com.stevesoltys.seedvault.transport
|
|||
|
||||
import android.app.Service
|
||||
import android.app.backup.BackupManager
|
||||
import android.app.backup.BackupManager.FLAG_NON_INCREMENTAL_BACKUP // ktlint-disable no-unused-imports
|
||||
import android.app.backup.IBackupManager
|
||||
import android.content.Context
|
||||
import android.content.Context.BACKUP_SERVICE // ktlint-disable no-unused-imports
|
||||
import android.content.Intent
|
||||
import android.os.IBinder
|
||||
import android.os.RemoteException
|
||||
|
|
@ -55,22 +53,27 @@ class ConfigurableBackupTransportService : Service(), KoinComponent {
|
|||
|
||||
@WorkerThread
|
||||
fun requestBackup(context: Context) {
|
||||
val packageService: PackageService = get().get()
|
||||
val packages = packageService.eligiblePackages
|
||||
val appTotals = packageService.expectedAppTotals
|
||||
val backupManager: IBackupManager = get().get()
|
||||
if (backupManager.isBackupEnabled) {
|
||||
val packageService: PackageService = get().get()
|
||||
val packages = packageService.eligiblePackages
|
||||
val appTotals = packageService.expectedAppTotals
|
||||
|
||||
val observer = NotificationBackupObserver(context, packages.size, appTotals)
|
||||
val result = try {
|
||||
val backupManager: IBackupManager = get().get()
|
||||
backupManager.requestBackup(packages, observer, BackupMonitor(), 0)
|
||||
} catch (e: RemoteException) {
|
||||
Log.e(TAG, "Error during backup: ", e)
|
||||
val nm: BackupNotificationManager = get().get()
|
||||
nm.onBackupError()
|
||||
}
|
||||
if (result == BackupManager.SUCCESS) {
|
||||
Log.i(TAG, "Backup succeeded ")
|
||||
val result = try {
|
||||
Log.d(TAG, "Backup is enabled, request backup...")
|
||||
val observer = NotificationBackupObserver(context, packages.size, appTotals)
|
||||
backupManager.requestBackup(packages, observer, BackupMonitor(), 0)
|
||||
} catch (e: RemoteException) {
|
||||
Log.e(TAG, "Error during backup: ", e)
|
||||
val nm: BackupNotificationManager = get().get()
|
||||
nm.onBackupError()
|
||||
}
|
||||
if (result == BackupManager.SUCCESS) {
|
||||
Log.i(TAG, "Backup succeeded ")
|
||||
} else {
|
||||
Log.e(TAG, "Backup failed: $result")
|
||||
}
|
||||
} else {
|
||||
Log.e(TAG, "Backup failed: $result")
|
||||
Log.i(TAG, "Backup is not enabled")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -321,7 +321,7 @@ internal class BackupCoordinator(
|
|||
?: throw AssertionError("Cancelling full backup, but no current package")
|
||||
Log.i(
|
||||
TAG, "Cancel full backup of ${packageInfo.packageName}" +
|
||||
" because of $state.cancelReason"
|
||||
" because of ${state.cancelReason}"
|
||||
)
|
||||
onPackageBackupError(packageInfo)
|
||||
full.cancelFullBackup()
|
||||
|
|
|
|||
|
|
@ -25,12 +25,6 @@ interface BackupPlugin {
|
|||
@Throws(IOException::class)
|
||||
suspend fun initializeDevice()
|
||||
|
||||
/**
|
||||
* Delete all existing [RestoreSet]s from the storage medium.
|
||||
*/
|
||||
@Throws(IOException::class)
|
||||
suspend fun deleteAllBackups()
|
||||
|
||||
/**
|
||||
* Returns an [OutputStream] for writing backup metadata.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import com.stevesoltys.seedvault.ui.storage.StorageViewModel
|
|||
abstract class RequireProvisioningViewModel(
|
||||
protected val app: Application,
|
||||
protected val settingsManager: SettingsManager,
|
||||
private val keyManager: KeyManager
|
||||
protected val keyManager: KeyManager
|
||||
) : AndroidViewModel(app) {
|
||||
|
||||
abstract val isRestoreOperation: Boolean
|
||||
|
|
|
|||
|
|
@ -0,0 +1,32 @@
|
|||
package com.stevesoltys.seedvault.ui.files
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import com.stevesoltys.seedvault.R
|
||||
import com.stevesoltys.seedvault.settings.SettingsViewModel
|
||||
import org.calyxos.backup.storage.ui.backup.BackupContentFragment
|
||||
import org.koin.androidx.viewmodel.ext.android.sharedViewModel
|
||||
import org.koin.androidx.viewmodel.ext.android.viewModel
|
||||
|
||||
class FileSelectionFragment() : BackupContentFragment() {
|
||||
|
||||
override val viewModel by viewModel<FileSelectionViewModel>()
|
||||
private val settingsViewModel by sharedViewModel<SettingsViewModel>()
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View {
|
||||
requireActivity().setTitle(R.string.settings_backup_files_title)
|
||||
return super.onCreateView(inflater, container, savedInstanceState)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
// reload files summary when we navigate away (it might have changed)
|
||||
settingsViewModel.loadFilesSummary()
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
package com.stevesoltys.seedvault.ui.files
|
||||
|
||||
import android.app.Application
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import kotlinx.coroutines.launch
|
||||
import org.calyxos.backup.storage.api.StorageBackup
|
||||
import org.calyxos.backup.storage.ui.backup.BackupContentViewModel
|
||||
|
||||
class FileSelectionViewModel(
|
||||
app: Application,
|
||||
override val storageBackup: StorageBackup
|
||||
) : BackupContentViewModel(app) {
|
||||
|
||||
init {
|
||||
viewModelScope.launch { loadContent() }
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -8,7 +8,7 @@ import androidx.recyclerview.widget.RecyclerView
|
|||
import androidx.recyclerview.widget.RecyclerView.Adapter
|
||||
import com.stevesoltys.seedvault.R
|
||||
|
||||
class RecoveryCodeAdapter(private val items: List<CharSequence>) :
|
||||
class RecoveryCodeAdapter(private val items: List<CharArray>) :
|
||||
Adapter<RecoveryCodeViewHolder>() {
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecoveryCodeViewHolder {
|
||||
|
|
@ -30,9 +30,9 @@ class RecoveryCodeViewHolder(v: View) : RecyclerView.ViewHolder(v) {
|
|||
private val num = v.findViewById<TextView>(R.id.num)
|
||||
private val word = v.findViewById<TextView>(R.id.word)
|
||||
|
||||
internal fun bind(number: Int, item: CharSequence) {
|
||||
internal fun bind(number: Int, item: CharArray) {
|
||||
num.text = number.toString()
|
||||
word.text = item
|
||||
word.text = String(item)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,15 +19,16 @@ import androidx.activity.result.contract.ActivityResultContracts.StartActivityFo
|
|||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.fragment.app.Fragment
|
||||
import cash.z.ecc.android.bip39.Mnemonics
|
||||
import cash.z.ecc.android.bip39.Mnemonics.ChecksumException
|
||||
import cash.z.ecc.android.bip39.Mnemonics.InvalidWordException
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
import com.google.android.material.textfield.TextInputLayout
|
||||
import com.stevesoltys.seedvault.R
|
||||
import com.stevesoltys.seedvault.isDebugBuild
|
||||
import com.stevesoltys.seedvault.ui.LiveEventHandler
|
||||
import io.github.novacrypto.bip39.Validation.InvalidChecksumException
|
||||
import io.github.novacrypto.bip39.Validation.WordNotFoundException
|
||||
import io.github.novacrypto.bip39.wordlists.English
|
||||
import org.koin.androidx.viewmodel.ext.android.sharedViewModel
|
||||
import java.util.Locale
|
||||
|
||||
internal const val ARG_FOR_NEW_CODE = "forVerifyingNewCode"
|
||||
|
||||
|
|
@ -62,7 +63,7 @@ class RecoveryCodeInputFragment : Fragment() {
|
|||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
): View {
|
||||
val v: View = inflater.inflate(R.layout.fragment_recovery_code_input, container, false)
|
||||
|
||||
introText = v.findViewById(R.id.introText)
|
||||
|
|
@ -93,13 +94,18 @@ class RecoveryCodeInputFragment : Fragment() {
|
|||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
activity?.setTitle(R.string.recovery_code_title)
|
||||
|
||||
if (viewModel.isRestore) {
|
||||
introText.setText(R.string.recovery_code_input_intro)
|
||||
backView.visibility = VISIBLE
|
||||
backView.setOnClickListener { requireActivity().finishAfterTransition() }
|
||||
}
|
||||
|
||||
val adapter = getAdapter()
|
||||
val adapterLayout = android.R.layout.simple_list_item_1
|
||||
val adapter = ArrayAdapter<String>(requireContext(), adapterLayout).apply {
|
||||
addAll(Mnemonics.getCachedWords(Locale.ENGLISH.language))
|
||||
}
|
||||
|
||||
for (i in 0 until WORD_NUM) {
|
||||
val wordLayout = getWordLayout(i)
|
||||
|
|
@ -120,14 +126,6 @@ class RecoveryCodeInputFragment : Fragment() {
|
|||
if (forVerifyingNewCode && isDebugBuild() && !viewModel.isRestore) debugPreFill()
|
||||
}
|
||||
|
||||
private fun getAdapter(): ArrayAdapter<String> {
|
||||
val adapter = ArrayAdapter<String>(requireContext(), android.R.layout.simple_list_item_1)
|
||||
for (i in 0 until WORD_LIST_SIZE) {
|
||||
adapter.add(English.INSTANCE.getWord(i))
|
||||
}
|
||||
return adapter
|
||||
}
|
||||
|
||||
private fun getInput(): List<CharSequence> = ArrayList<String>(WORD_NUM).apply {
|
||||
for (i in 0 until WORD_NUM) add(getWordLayout(i).editText!!.text.toString())
|
||||
}
|
||||
|
|
@ -137,10 +135,10 @@ class RecoveryCodeInputFragment : Fragment() {
|
|||
if (!allFilledOut(input)) return
|
||||
try {
|
||||
viewModel.validateAndContinue(input, forVerifyingNewCode)
|
||||
} catch (e: InvalidChecksumException) {
|
||||
} catch (e: ChecksumException) {
|
||||
Toast.makeText(context, R.string.recovery_code_error_checksum_word, LENGTH_LONG).show()
|
||||
} catch (e: WordNotFoundException) {
|
||||
showWrongWordError(input, e)
|
||||
} catch (e: InvalidWordException) {
|
||||
showWrongWordError(input)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -153,10 +151,11 @@ class RecoveryCodeInputFragment : Fragment() {
|
|||
return true
|
||||
}
|
||||
|
||||
private fun showWrongWordError(input: List<CharSequence>, e: WordNotFoundException) {
|
||||
val i = input.indexOf(e.word)
|
||||
private fun showWrongWordError(input: List<CharSequence>) {
|
||||
val words = Mnemonics.getCachedWords(Locale.ENGLISH.language)
|
||||
val i = input.indexOfFirst { it !in words }
|
||||
if (i == -1) throw AssertionError()
|
||||
val str = getString(R.string.recovery_code_error_invalid_word, e.suggestion1, e.suggestion2)
|
||||
val str = getString(R.string.recovery_code_error_invalid_word)
|
||||
showError(i, str)
|
||||
}
|
||||
|
||||
|
|
@ -190,7 +189,7 @@ class RecoveryCodeInputFragment : Fragment() {
|
|||
|
||||
private val regenRequest = registerForActivityResult(StartActivityForResult()) {
|
||||
if (it.resultCode == RESULT_OK) {
|
||||
viewModel.deleteAllBackup()
|
||||
viewModel.reinitializeBackupLocation()
|
||||
parentFragmentManager.popBackStack()
|
||||
Snackbar.make(requireView(), R.string.recovery_code_recreated, Snackbar.LENGTH_LONG)
|
||||
.show()
|
||||
|
|
@ -233,7 +232,7 @@ class RecoveryCodeInputFragment : Fragment() {
|
|||
private fun debugPreFill() {
|
||||
val words = viewModel.wordList
|
||||
for (i in words.indices) {
|
||||
getWordLayout(i).editText!!.setText(words[i])
|
||||
getWordLayout(i).editText!!.setText(String(words[i]))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ class RecoveryCodeOutputFragment : Fragment() {
|
|||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
): View {
|
||||
val v: View = inflater.inflate(R.layout.fragment_recovery_code_output, container, false)
|
||||
|
||||
wordList = v.findViewById(R.id.wordList)
|
||||
|
|
|
|||
|
|
@ -1,48 +1,47 @@
|
|||
package com.stevesoltys.seedvault.ui.recoverycode
|
||||
|
||||
import android.app.backup.IBackupManager
|
||||
import android.os.UserHandle
|
||||
import android.util.Log
|
||||
import androidx.lifecycle.AndroidViewModel
|
||||
import cash.z.ecc.android.bip39.Mnemonics
|
||||
import cash.z.ecc.android.bip39.Mnemonics.ChecksumException
|
||||
import cash.z.ecc.android.bip39.Mnemonics.InvalidWordException
|
||||
import cash.z.ecc.android.bip39.Mnemonics.WordCountException
|
||||
import cash.z.ecc.android.bip39.toSeed
|
||||
import com.stevesoltys.seedvault.App
|
||||
import com.stevesoltys.seedvault.crypto.Crypto
|
||||
import com.stevesoltys.seedvault.crypto.KeyManager
|
||||
import com.stevesoltys.seedvault.transport.backup.BackupPlugin
|
||||
import com.stevesoltys.seedvault.transport.TRANSPORT_ID
|
||||
import com.stevesoltys.seedvault.transport.backup.BackupCoordinator
|
||||
import com.stevesoltys.seedvault.ui.LiveEvent
|
||||
import com.stevesoltys.seedvault.ui.MutableLiveEvent
|
||||
import io.github.novacrypto.bip39.JavaxPBKDF2WithHmacSHA512
|
||||
import io.github.novacrypto.bip39.MnemonicGenerator
|
||||
import io.github.novacrypto.bip39.MnemonicValidator
|
||||
import io.github.novacrypto.bip39.SeedCalculator
|
||||
import io.github.novacrypto.bip39.Validation.InvalidChecksumException
|
||||
import io.github.novacrypto.bip39.Validation.InvalidWordCountException
|
||||
import io.github.novacrypto.bip39.Validation.UnexpectedWhiteSpaceException
|
||||
import io.github.novacrypto.bip39.Validation.WordNotFoundException
|
||||
import io.github.novacrypto.bip39.Words
|
||||
import io.github.novacrypto.bip39.wordlists.English
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.launch
|
||||
import org.calyxos.backup.storage.api.StorageBackup
|
||||
import java.io.IOException
|
||||
import java.security.SecureRandom
|
||||
import java.util.ArrayList
|
||||
|
||||
internal const val WORD_NUM = 12
|
||||
internal const val WORD_LIST_SIZE = 2048
|
||||
|
||||
class RecoveryCodeViewModel(
|
||||
private val TAG = RecoveryCodeViewModel::class.java.simpleName
|
||||
|
||||
internal class RecoveryCodeViewModel(
|
||||
app: App,
|
||||
private val crypto: Crypto,
|
||||
private val keyManager: KeyManager,
|
||||
private val backupPlugin: BackupPlugin
|
||||
private val backupManager: IBackupManager,
|
||||
private val backupCoordinator: BackupCoordinator,
|
||||
private val storageBackup: StorageBackup
|
||||
) : AndroidViewModel(app) {
|
||||
|
||||
internal val wordList: List<CharSequence> by lazy {
|
||||
val items: ArrayList<CharSequence> = ArrayList(WORD_NUM)
|
||||
val entropy = ByteArray(Words.TWELVE.byteLength())
|
||||
internal val wordList: List<CharArray> by lazy {
|
||||
// we use our own entropy to not having to trust the library to use SecureRandom
|
||||
val entropy = ByteArray(Mnemonics.WordCount.COUNT_12.bitLength / 8)
|
||||
SecureRandom().nextBytes(entropy)
|
||||
MnemonicGenerator(English.INSTANCE).createMnemonic(entropy) {
|
||||
if (it != " ") items.add(it)
|
||||
}
|
||||
items
|
||||
// create the words from the entropy
|
||||
Mnemonics.MnemonicCode(entropy).words
|
||||
}
|
||||
|
||||
private val mConfirmButtonClicked = MutableLiveEvent<Boolean>()
|
||||
|
|
@ -57,17 +56,15 @@ class RecoveryCodeViewModel(
|
|||
|
||||
internal var isRestore: Boolean = false
|
||||
|
||||
@Throws(WordNotFoundException::class, InvalidChecksumException::class)
|
||||
@Throws(InvalidWordException::class, ChecksumException::class)
|
||||
fun validateAndContinue(input: List<CharSequence>, forVerifyingNewCode: Boolean) {
|
||||
val code = Mnemonics.MnemonicCode(input.toMnemonicChars())
|
||||
try {
|
||||
MnemonicValidator.ofWordList(English.INSTANCE).validate(input)
|
||||
} catch (e: UnexpectedWhiteSpaceException) {
|
||||
throw AssertionError(e)
|
||||
} catch (e: InvalidWordCountException) {
|
||||
code.validate()
|
||||
} catch (e: WordCountException) {
|
||||
throw AssertionError(e)
|
||||
}
|
||||
val mnemonic = input.joinToString(" ")
|
||||
val seed = SeedCalculator(JavaxPBKDF2WithHmacSHA512.INSTANCE).calculateSeed(mnemonic, "")
|
||||
val seed = code.toSeed()
|
||||
if (forVerifyingNewCode) {
|
||||
keyManager.storeBackupKey(seed)
|
||||
keyManager.storeMainKey(seed)
|
||||
|
|
@ -79,14 +76,38 @@ class RecoveryCodeViewModel(
|
|||
}
|
||||
}
|
||||
|
||||
fun deleteAllBackup() {
|
||||
/**
|
||||
* Deletes all storage backups for current user and clears the storage backup cache.
|
||||
* Also starts a new app data restore set and initializes it.
|
||||
*
|
||||
* The reason is that old backups won't be readable anymore with the new key.
|
||||
* We can't delete other backups safely, because we can't be sure
|
||||
* that they don't belong to a different device or user.
|
||||
*/
|
||||
fun reinitializeBackupLocation() {
|
||||
Log.d(TAG, "Re-initializing backup location...")
|
||||
GlobalScope.launch(Dispatchers.IO) {
|
||||
// remove old storage snapshots and clear cache
|
||||
storageBackup.deleteAllSnapshots()
|
||||
storageBackup.clearCache()
|
||||
try {
|
||||
backupPlugin.deleteAllBackups()
|
||||
// will also generate a new backup token for the new restore set
|
||||
backupCoordinator.startNewRestoreSet()
|
||||
|
||||
// initialize the new location
|
||||
backupManager.initializeTransportsForUser(
|
||||
UserHandle.myUserId(),
|
||||
arrayOf(TRANSPORT_ID),
|
||||
null
|
||||
)
|
||||
} catch (e: IOException) {
|
||||
Log.e("RecoveryCodeViewModel", "Error deleting backups", e)
|
||||
Log.e(TAG, "Error starting new RestoreSet", e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
internal fun List<CharSequence>.toMnemonicChars(): CharArray {
|
||||
return joinToString(" ").toCharArray()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import com.stevesoltys.seedvault.transport.backup.BackupCoordinator
|
|||
import com.stevesoltys.seedvault.transport.requestBackup
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import org.calyxos.backup.storage.api.StorageBackup
|
||||
import java.io.IOException
|
||||
|
||||
private val TAG = BackupStorageViewModel::class.java.simpleName
|
||||
|
|
@ -24,6 +25,7 @@ internal class BackupStorageViewModel(
|
|||
private val app: Application,
|
||||
private val backupManager: IBackupManager,
|
||||
private val backupCoordinator: BackupCoordinator,
|
||||
private val storageBackup: StorageBackup,
|
||||
settingsManager: SettingsManager
|
||||
) : StorageViewModel(app, settingsManager) {
|
||||
|
||||
|
|
@ -32,6 +34,9 @@ internal class BackupStorageViewModel(
|
|||
override fun onLocationSet(uri: Uri) {
|
||||
val isUsb = saveStorage(uri)
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
// remove old storage snapshots and clear cache
|
||||
storageBackup.deleteAllSnapshots()
|
||||
storageBackup.clearCache()
|
||||
try {
|
||||
// will also generate a new backup token for the new restore set
|
||||
backupCoordinator.startNewRestoreSet()
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.stevesoltys.seedvault.ui.storage
|
|||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.View.GONE
|
||||
import android.view.View.INVISIBLE
|
||||
import android.view.View.VISIBLE
|
||||
import android.view.ViewGroup
|
||||
|
|
@ -37,7 +38,7 @@ class StorageCheckFragment : Fragment() {
|
|||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
): View {
|
||||
val v: View = inflater.inflate(R.layout.fragment_storage_check, container, false)
|
||||
|
||||
titleView = v.findViewById(R.id.titleView)
|
||||
|
|
@ -55,6 +56,7 @@ class StorageCheckFragment : Fragment() {
|
|||
|
||||
val errorMsg = requireArguments().getString(ERROR_MSG)
|
||||
if (errorMsg != null) {
|
||||
view.findViewById<View>(R.id.patienceView).visibility = GONE
|
||||
progressBar.visibility = INVISIBLE
|
||||
errorView.text = errorMsg
|
||||
errorView.visibility = VISIBLE
|
||||
|
|
|
|||
|
|
@ -83,6 +83,9 @@ internal class StorageRootsFragment : Fragment(), StorageRootClickedListener {
|
|||
backView.setOnClickListener { requireActivity().finishAfterTransition() }
|
||||
} else {
|
||||
warningIcon.visibility = VISIBLE
|
||||
if (viewModel.hasStorageSet) {
|
||||
warningText.setText(R.string.storage_fragment_warning_delete)
|
||||
}
|
||||
warningText.visibility = VISIBLE
|
||||
divider.visibility = VISIBLE
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,6 +41,8 @@ internal abstract class StorageViewModel(
|
|||
private var storageRoot: StorageRoot? = null
|
||||
|
||||
internal var isSetupWizard: Boolean = false
|
||||
internal val hasStorageSet: Boolean
|
||||
get() = settingsManager.getStorage() != null
|
||||
abstract val isRestoreOperation: Boolean
|
||||
|
||||
companion object {
|
||||
|
|
|
|||
10
app/src/main/res/drawable/ic_library_add.xml
Normal file
10
app/src/main/res/drawable/ic_library_add.xml
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:tint="?android:attr/colorControlNormal"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M4,6L2,6v14c0,1.1 0.9,2 2,2h14v-2L4,20L4,6zM20,2L8,2c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2L22,4c0,-1.1 -0.9,-2 -2,-2zM19,11h-4v4h-2v-4L9,11L9,9h4L13,5h2v4h4v2z" />
|
||||
</vector>
|
||||
10
app/src/main/res/drawable/ic_save_alt.xml
Normal file
10
app/src/main/res/drawable/ic_save_alt.xml
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:tint="?android:attr/colorControlNormal"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M19,12v7L5,19v-7L3,12v7c0,1.1 0.9,2 2,2h14c1.1,0 2,-0.9 2,-2v-7h-2zM13,12.67l2.59,-2.58L17,11.5l-5,5 -5,-5 1.41,-1.41L11,12.67L11,3h2z" />
|
||||
</vector>
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:tint="?attr/colorControlNormal"
|
||||
android:tint="?android:attr/colorControlNormal"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
|
|
|
|||
19
app/src/main/res/layout/footer_snapshots.xml
Normal file
19
app/src/main/res/layout/footer_snapshots.xml
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/skipView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?android:selectableItemBackground"
|
||||
android:padding="16dp"
|
||||
android:text="@string/restore_storage_skip"
|
||||
android:textColor="?android:colorAccent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
|
@ -60,6 +60,7 @@
|
|||
|
||||
<Button
|
||||
android:id="@+id/doneButton"
|
||||
style="@style/ActionPrimaryButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
|
|
@ -74,7 +75,8 @@
|
|||
android:id="@+id/backView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="16dp"
|
||||
android:background="?android:selectableItemBackground"
|
||||
android:padding="16dp"
|
||||
android:text="@string/restore_back"
|
||||
android:textColor="?android:colorAccent"
|
||||
android:visibility="gone"
|
||||
|
|
|
|||
|
|
@ -57,19 +57,21 @@
|
|||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/wordList"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:layout_height="0dp"
|
||||
android:scrollbars="vertical"
|
||||
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
|
||||
app:layout_constraintBottom_toTopOf="@+id/confirmCodeButton"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/divider"
|
||||
app:layout_constraintVertical_chainStyle="spread_inside"
|
||||
app:spanCount="2"
|
||||
tools:itemCount="12"
|
||||
tools:listitem="@layout/list_item_recovery_code_output" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/confirmCodeButton"
|
||||
style="@style/ActionPrimaryButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
|
|
@ -78,6 +80,7 @@
|
|||
android:text="@string/recovery_code_confirm_button"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/wordList" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
56
app/src/main/res/layout/fragment_restore_files_started.xml
Normal file
56
app/src/main/res/layout/fragment_restore_files_started.xml
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageView"
|
||||
android:layout_width="32dp"
|
||||
android:layout_height="32dp"
|
||||
android:layout_margin="16dp"
|
||||
android:tint="?android:colorAccent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:srcCompat="@drawable/ic_cloud_restore"
|
||||
tools:ignore="ContentDescription" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/titleView"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="16dp"
|
||||
android:gravity="center"
|
||||
android:text="@string/restore_storage_in_progress_title"
|
||||
android:textSize="24sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/imageView" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/infoView"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="16dp"
|
||||
android:text="@string/restore_storage_in_progress_info"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/titleView" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button"
|
||||
style="@style/Widget.AppCompat.Button.Colored"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="16dp"
|
||||
android:text="@string/restore_storage_got_it"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="1.0"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/infoView"
|
||||
app:layout_constraintVertical_bias="1.0" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
|
@ -68,7 +68,7 @@
|
|||
|
||||
<Button
|
||||
android:id="@+id/button"
|
||||
style="@style/Widget.AppCompat.Button.Colored"
|
||||
style="@style/ActionPrimaryButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@
|
|||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||
app:layout_constraintBottom_toTopOf="@+id/backView"
|
||||
app:layout_constraintBottom_toTopOf="@+id/skipView"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/titleView"
|
||||
|
|
@ -47,7 +47,7 @@
|
|||
style="?android:progressBarStyleLarge"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintBottom_toTopOf="@+id/backView"
|
||||
app:layout_constraintBottom_toTopOf="@+id/skipView"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/titleView" />
|
||||
|
|
@ -57,10 +57,10 @@
|
|||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="16dp"
|
||||
android:textColor="@android:color/holo_red_dark"
|
||||
android:textColor="?android:colorError"
|
||||
android:textSize="18sp"
|
||||
android:visibility="invisible"
|
||||
app:layout_constraintBottom_toTopOf="@+id/backView"
|
||||
app:layout_constraintBottom_toTopOf="@+id/skipView"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/titleView"
|
||||
|
|
@ -68,11 +68,12 @@
|
|||
tools:visibility="visible" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/backView"
|
||||
android:id="@+id/skipView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="16dp"
|
||||
android:text="@string/restore_back"
|
||||
android:background="?android:selectableItemBackground"
|
||||
android:padding="16dp"
|
||||
android:text="@string/restore_skip"
|
||||
android:textColor="?android:colorAccent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
|
|
|
|||
|
|
@ -29,6 +29,17 @@
|
|||
app:layout_constraintTop_toBottomOf="@+id/imageView"
|
||||
tools:text="@string/storage_check_fragment_backup_title" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/patienceView"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="16dp"
|
||||
android:gravity="center_horizontal"
|
||||
android:text="@string/storage_check_fragment_patience"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/titleView" />
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progressBar"
|
||||
style="?android:progressBarStyleLarge"
|
||||
|
|
@ -37,10 +48,10 @@
|
|||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="32dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintBottom_toTopOf="@+id/backButton"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/titleView"
|
||||
app:layout_constraintTop_toBottomOf="@+id/patienceView"
|
||||
app:layout_constraintVertical_bias="0.0" />
|
||||
|
||||
<TextView
|
||||
|
|
@ -50,20 +61,20 @@
|
|||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="32dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:textColor="@android:color/holo_red_dark"
|
||||
android:textColor="?android:colorError"
|
||||
android:textSize="18sp"
|
||||
android:visibility="invisible"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/titleView"
|
||||
app:layout_constraintTop_toBottomOf="@+id/patienceView"
|
||||
app:layout_constraintVertical_bias="0.0"
|
||||
tools:text="@string/storage_check_fragment_backup_error"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/backButton"
|
||||
style="@style/Widget.AppCompat.Button.Colored"
|
||||
style="@style/ActionPrimaryButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="16dp"
|
||||
|
|
|
|||
|
|
@ -22,24 +22,24 @@
|
|||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="16dp"
|
||||
android:gravity="center"
|
||||
android:text="@string/storage_fragment_backup_title"
|
||||
android:textSize="24sp"
|
||||
android:gravity="center"
|
||||
tools:text="Choose where to store backup (is a short title, but it can be longer)"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/imageView" />
|
||||
app:layout_constraintTop_toBottomOf="@+id/imageView"
|
||||
tools:text="Choose where to store backup (is a short title, but it can be longer)" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/warningIcon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="24dp"
|
||||
android:src="@drawable/ic_warning"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/warningText"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/titleView"
|
||||
app:layout_constraintTop_toTopOf="@+id/warningText"
|
||||
tools:ignore="ContentDescription"
|
||||
tools:visibility="visible" />
|
||||
|
||||
|
|
@ -96,7 +96,8 @@
|
|||
android:id="@+id/backView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="16dp"
|
||||
android:background="?android:selectableItemBackground"
|
||||
android:padding="16dp"
|
||||
android:text="@string/restore_back"
|
||||
android:textColor="?android:colorAccent"
|
||||
android:visibility="gone"
|
||||
|
|
|
|||
33
app/src/main/res/layout/header_snapshots.xml
Normal file
33
app/src/main/res/layout/header_snapshots.xml
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageView"
|
||||
android:layout_width="32dp"
|
||||
android:layout_height="32dp"
|
||||
android:layout_margin="16dp"
|
||||
android:tint="?android:colorAccent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:srcCompat="@drawable/ic_cloud_download"
|
||||
tools:ignore="ContentDescription" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/titleView"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="16dp"
|
||||
android:gravity="center"
|
||||
android:text="@string/restore_storage_choose_snapshot"
|
||||
android:textSize="24sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/imageView" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
|
@ -4,7 +4,8 @@
|
|||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="24dp"
|
||||
android:layout_marginTop="24dp"
|
||||
android:layout_marginBottom="24dp"
|
||||
tools:showIn="@layout/fragment_recovery_code_output">
|
||||
|
||||
<TextView
|
||||
|
|
@ -25,12 +26,12 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:autoSizeTextType="uniform"
|
||||
android:textSize="24sp"
|
||||
app:layout_constrainedWidth="true"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/num"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:text="Test1" />
|
||||
tools:text="Test1CanBeLong" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
|
@ -18,7 +18,7 @@
|
|||
<string name="notification_title">Sicherung läuft</string>
|
||||
<string name="notification_channel_title">Sicherungsbenachrichtigung</string>
|
||||
<string name="recovery_code_error_checksum_word">Ihr Wiederherstellungsschlüssel ist ungültig. Bitte prüfen Sie alle eingegebenen Wörter und versuchen Sie es erneut!</string>
|
||||
<string name="recovery_code_error_invalid_word">Falsches Wort. Meinten Sie %1$s oder %2$s\?</string>
|
||||
<string name="recovery_code_error_invalid_word">Falsches Wort.</string>
|
||||
<string name="recovery_code_error_empty_word">Sie vergaßen, dieses Wort einzugeben.</string>
|
||||
<string name="recovery_code_input_hint_12">Wort 12</string>
|
||||
<string name="recovery_code_input_hint_11">Wort 11</string>
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@
|
|||
<string name="notification_title">Εκτελείται δημιουργία αντιγράφων ασφαλείας</string>
|
||||
<string name="notification_channel_title">Ειδοποίηση δημιουργίας αντιγράφων ασφαλείας</string>
|
||||
<string name="recovery_code_error_checksum_word">Ο κωδικός σας δεν είναι έγκυρος. Ελέγξτε όλες τις λέξεις και δοκιμάστε ξανά!</string>
|
||||
<string name="recovery_code_error_invalid_word">Λάθος λέξη. Εννοείτε %1$s ή %2$s;</string>
|
||||
<string name="recovery_code_error_invalid_word">Λάθος λέξη.</string>
|
||||
<string name="recovery_code_error_empty_word">Ξεχάσατε να εισαγάγετε αυτήν τη λέξη.</string>
|
||||
<string name="recovery_code_input_hint_12">Λέξη 12</string>
|
||||
<string name="recovery_code_input_hint_11">Λέξη 11</string>
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@
|
|||
<string name="notification_success_title">Respaldo terminó</string>
|
||||
<string name="notification_title">Ejecución de respaldo</string>
|
||||
<string name="recovery_code_error_checksum_word">Tu código no es válido. Por favor revise todas las palabras e intente nuevamente!</string>
|
||||
<string name="recovery_code_error_invalid_word">Palabra equivocada. ¿Quisiste decir %1$s o %2$s\?</string>
|
||||
<string name="recovery_code_error_invalid_word">Palabra equivocada.</string>
|
||||
<string name="recovery_code_error_empty_word">Olvidaste ingresar esta palabra.</string>
|
||||
<string name="recovery_code_input_hint_12">Palabra 12</string>
|
||||
<string name="recovery_code_input_hint_11">Palabra 11</string>
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@
|
|||
<string name="notification_title">Copia de seguridad en ejecución</string>
|
||||
<string name="notification_channel_title">Notificación de copia de seguridad</string>
|
||||
<string name="recovery_code_error_checksum_word">Su código es inválido. Por favor, compruebe todas las palabras e inténtelo de nuevo!</string>
|
||||
<string name="recovery_code_error_invalid_word">Palabra equivocada. ¿Quisiste decir %1$s o %2$s \?</string>
|
||||
<string name="recovery_code_error_invalid_word">Palabra equivocada.</string>
|
||||
<string name="recovery_code_input_intro">Ingrese su código de recuperación de 12 palabras que anotó al configurar las copias de seguridad.</string>
|
||||
<string name="recovery_code_confirm_intro">Ingrese su código de recuperación de 12 palabras para asegurarse de que funcionará cuando lo necesite.</string>
|
||||
<string name="recovery_code_confirm_button">Confirma código</string>
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
<string name="notification_error_action">Réparer</string>
|
||||
<string name="notification_channel_title">Notification de la sauvegarde</string>
|
||||
<string name="recovery_code_error_checksum_word">Votre code est invalide. Veuillez vérifier tous les mots et réessayer !</string>
|
||||
<string name="recovery_code_error_invalid_word">Mot erroné. Vouliez-vous dire %1$s ou %2$s \?</string>
|
||||
<string name="recovery_code_error_invalid_word">Mot erroné.</string>
|
||||
<string name="recovery_code_error_empty_word">Vous avez oublié d’entrer ce mot.</string>
|
||||
<string name="recovery_code_input_hint_12">Mot 12</string>
|
||||
<string name="recovery_code_input_hint_11">Mot 11</string>
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
<string name="notification_title">הגיבוי פועל</string>
|
||||
<string name="notification_channel_title">התראת גיבוי</string>
|
||||
<string name="recovery_code_error_checksum_word">הקוד שלך שגוי. נא לאמת את כל המילים ולנסות שוב!</string>
|
||||
<string name="recovery_code_error_invalid_word">מילה שגויה. התכוונת למילה %1$s או %2$s\?</string>
|
||||
<string name="recovery_code_error_invalid_word">מילה שגויה.</string>
|
||||
<string name="recovery_code_error_empty_word">שכחת למלא את המילה הזאת.</string>
|
||||
<string name="recovery_code_input_hint_12">מילה 12</string>
|
||||
<string name="recovery_code_input_hint_11">מילה 11</string>
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@
|
|||
<string name="notification_title">Sigurnosna kopija pokrenuta</string>
|
||||
<string name="notification_channel_title">Obavijest sigurnosne kopije</string>
|
||||
<string name="recovery_code_error_checksum_word">Tvoja lozinka je neispravna. Provjeri sve riječi i pokušaj ponovo!</string>
|
||||
<string name="recovery_code_error_invalid_word">Kriva riječ. Je li misliš %1$s ili %2$s\?</string>
|
||||
<string name="recovery_code_error_invalid_word">Kriva riječ.</string>
|
||||
<string name="recovery_code_error_empty_word">Ova riječ nije upisana.</string>
|
||||
<string name="recovery_code_input_hint_12">Riječ 12</string>
|
||||
<string name="recovery_code_input_hint_11">Riječ 11</string>
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@
|
|||
<string name="notification_title">Öryggisafritun í gangi</string>
|
||||
<string name="notification_channel_title">Tilkynning um öryggisafritatöku</string>
|
||||
<string name="recovery_code_error_checksum_word">Kóðinn er ógildur. Athugað öll orðin og prófaðu aftur!</string>
|
||||
<string name="recovery_code_error_invalid_word">Rangt orð. Meintirðu %1$s or %2$s\?</string>
|
||||
<string name="recovery_code_error_invalid_word">Rangt orð.</string>
|
||||
<string name="recovery_code_error_empty_word">Þú gleymdir að slá inn þetta orð.</string>
|
||||
<string name="recovery_code_input_hint_12">Orð 12</string>
|
||||
<string name="recovery_code_input_hint_11">Orð 11</string>
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
<string name="notification_title">Backup in esecuzione</string>
|
||||
<string name="notification_channel_title">Notificazione backup</string>
|
||||
<string name="recovery_code_error_checksum_word">Il tuo codice non è valido, Controlla tutte le parole e riprova!</string>
|
||||
<string name="recovery_code_error_invalid_word">Parola sbagliata. Intendevi %1$s o %2$s\?</string>
|
||||
<string name="recovery_code_error_invalid_word">Parola sbagliata.</string>
|
||||
<string name="recovery_code_error_empty_word">Hai dimenticato di inserire questa parola.</string>
|
||||
<string name="recovery_code_input_hint_12">Parola 12</string>
|
||||
<string name="recovery_code_input_hint_11">Parola 11</string>
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@
|
|||
<string name="notification_restore_error_action">앱 설치 제거</string>
|
||||
<string name="notification_backup_already_running">백업이 이미 진행 중</string>
|
||||
<string name="recovery_code_error_checksum_word">코드가 잘못되었습니다. 모든 단어를 확인하고 다시 시도하세요!</string>
|
||||
<string name="recovery_code_error_invalid_word">단어가 틀렸습니다. %1$s 또는 %2$s를 입력하려고 하셨나요\?</string>
|
||||
<string name="recovery_code_error_invalid_word">단어가 틀렸습니다.</string>
|
||||
<string name="recovery_code_error_empty_word">이 단어를 입력하지 않았습니다.</string>
|
||||
<string name="recovery_code_confirm_intro">복구 코드가 맞는지 확인하려면 12개 단어로 이루어진 복구 코드를 입력하세요.</string>
|
||||
<string name="recovery_code_input_intro">백업을 설정할 때 지정했던 12개 단어로 이루어진 복구 코드를 입력하세요.</string>
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@
|
|||
<string name="notification_title">Sikkerhetskopiering utføres</string>
|
||||
<string name="notification_channel_title">Sikkerhetskopieringsmerknad</string>
|
||||
<string name="recovery_code_error_checksum_word">Koden din er ugyldig. Sjekk alle ordene og prøv igjen.</string>
|
||||
<string name="recovery_code_error_invalid_word">Feil ord. Mente du %1$s eller %2$s\?</string>
|
||||
<string name="recovery_code_error_invalid_word">Feil ord.</string>
|
||||
<string name="recovery_code_error_empty_word">Du glemte å skrive inn dette ordet.</string>
|
||||
<string name="recovery_code_input_hint_12">Ord 12</string>
|
||||
<string name="recovery_code_input_hint_11">Ord 11</string>
|
||||
|
|
|
|||
4
app/src/main/res/values-night/bools.xml
Normal file
4
app/src/main/res/values-night/bools.xml
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<bool name="isLight">false</bool>
|
||||
</resources>
|
||||
10
app/src/main/res/values-night/colors.xml
Normal file
10
app/src/main/res/values-night/colors.xml
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="accent">@*android:color/accent_device_default_dark</color>
|
||||
<color name="primary">@*android:color/primary_device_default_settings</color>
|
||||
<color name="primaryDark">@*android:color/primary_dark_device_default_settings</color>
|
||||
<color name="background">@color/primaryDark</color>
|
||||
<color name="actionBarPrimary">@color/background</color>
|
||||
<color name="statusBarColor">@android:color/transparent</color>
|
||||
<color name="red">@*android:color/error_color_device_default_dark</color>
|
||||
</resources>
|
||||
|
|
@ -12,7 +12,7 @@
|
|||
<string name="notification_title">Backup em execução</string>
|
||||
<string name="notification_channel_title">Notificação de backup</string>
|
||||
<string name="recovery_code_error_checksum_word">Seu código é inválido. Por favor, verifique todas as palavras e tente novamente!</string>
|
||||
<string name="recovery_code_error_invalid_word">Palavra errada. Você quis dizer %1$s ou %2$s\?</string>
|
||||
<string name="recovery_code_error_invalid_word">Palavra errada.</string>
|
||||
<string name="recovery_code_error_empty_word">Você se esqueceu de inserir esta palavra.</string>
|
||||
<string name="recovery_code_input_hint_12">Palavra 12</string>
|
||||
<string name="recovery_code_input_hint_11">Palavra 11</string>
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@
|
|||
<string name="notification_title">Backup em execução</string>
|
||||
<string name="notification_channel_title">Notificação de backup</string>
|
||||
<string name="recovery_code_error_checksum_word">Seu código é inválido. Por favor, verifique todas as palavras e tente novamente!</string>
|
||||
<string name="recovery_code_error_invalid_word">Palavra errada. Quis dizer %1$s ou %2$s\?</string>
|
||||
<string name="recovery_code_error_invalid_word">Palavra errada.</string>
|
||||
<string name="recovery_code_error_empty_word">Se esqueceu de inserir esta palavra.</string>
|
||||
<string name="recovery_code_input_hint_12">Palavra 12</string>
|
||||
<string name="recovery_code_input_hint_11">Palavra 11</string>
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@
|
|||
<string name="notification_title">Резервное копирование запущено</string>
|
||||
<string name="notification_channel_title">Уведомление о резервном копировании</string>
|
||||
<string name="recovery_code_error_checksum_word">Ваш код недействителен. Пожалуйста, проверьте все слова и попробуйте еще раз!</string>
|
||||
<string name="recovery_code_error_invalid_word">Неверное слово. Вы имели в виду %1$s или %2$s\?</string>
|
||||
<string name="recovery_code_error_invalid_word">Неверное слово.</string>
|
||||
<string name="recovery_code_error_empty_word">Вы забыли ввести это слово.</string>
|
||||
<string name="recovery_code_input_hint_12">Слово 12</string>
|
||||
<string name="recovery_code_input_hint_11">Слово 11</string>
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@
|
|||
<string name="notification_title">Yedekleme çalışıyor</string>
|
||||
<string name="notification_channel_title">Yedekleme bildirimi</string>
|
||||
<string name="recovery_code_error_checksum_word">Kodunuz geçersiz. Lütfen tüm sözcükleri gözden geçirin ve tekrar deneyin!</string>
|
||||
<string name="recovery_code_error_invalid_word">Yanlış sözcük. %1$s veya %2$s demek mi istediniz\?</string>
|
||||
<string name="recovery_code_error_invalid_word">Yanlış sözcük.</string>
|
||||
<string name="recovery_code_error_empty_word">Bu sözcüğü girmeyi unuttunuz.</string>
|
||||
<string name="recovery_code_input_hint_12">12. sözcük</string>
|
||||
<string name="recovery_code_input_hint_11">11. sözcük</string>
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@
|
|||
<string name="notification_title">备份运行中</string>
|
||||
<string name="notification_channel_title">备份提示</string>
|
||||
<string name="recovery_code_error_checksum_word">您的代码无效。请检查所有单词,然后重试!</string>
|
||||
<string name="recovery_code_error_invalid_word">错误的词。你的意思是%1$s或%2$s?</string>
|
||||
<string name="recovery_code_error_invalid_word">错误的词。</string>
|
||||
<string name="recovery_code_error_empty_word">你忘了输入这个词。</string>
|
||||
<string name="recovery_code_done_button">完成</string>
|
||||
<string name="recovery_code_confirm_button">确认代码</string>
|
||||
|
|
|
|||
4
app/src/main/res/values/bools.xml
Normal file
4
app/src/main/res/values/bools.xml
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<bool name="isLight">true</bool>
|
||||
</resources>
|
||||
|
|
@ -1,8 +1,13 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="accent">#99cc00</color>
|
||||
<color name="divider">#8A000000</color>
|
||||
<color name="accent">@*android:color/accent_device_default_light</color>
|
||||
<color name="primary">@*android:color/primary_device_default_settings_light</color>
|
||||
<color name="primaryDark">@*android:color/primary_dark_device_default_settings_light</color>
|
||||
<color name="background">@*android:color/background_device_default_light</color>
|
||||
<color name="actionBarPrimary">@*android:color/primary_device_default_light</color>
|
||||
<color name="statusBarColor">@*android:color/primary_dark_material_light_light_status_bar</color>
|
||||
<color name="red">@*android:color/error_color_device_default_dark</color>
|
||||
<color name="divider">#20ffffff</color>
|
||||
<color name="green">#558B2F</color>
|
||||
<color name="red">#D32F2F</color>
|
||||
<color name="yellow">#F9A825</color>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -8,7 +8,8 @@
|
|||
<string name="restore_backup_button">Restore backup</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="settings_backup">Backup my data</string>
|
||||
<string name="settings_category_apps">App backup</string>
|
||||
<string name="settings_backup">Backup my apps</string>
|
||||
<string name="settings_backup_location">Backup location</string>
|
||||
<string name="settings_backup_location_none">None</string>
|
||||
<string name="settings_backup_location_internal">Internal storage</string>
|
||||
|
|
@ -28,21 +29,33 @@
|
|||
<string name="settings_backup_status_summary">Last backup: %1$s</string>
|
||||
<string name="settings_backup_exclude_apps">Exclude apps</string>
|
||||
<string name="settings_backup_now">Backup now</string>
|
||||
<string name="settings_backup_recovery_code">Recovery Code</string>
|
||||
<string name="settings_category_storage">Storage backup (experimental)</string>
|
||||
<string name="settings_backup_storage_title">Backup my files</string>
|
||||
<string name="settings_backup_files_title">Included files and folders</string>
|
||||
<string name="settings_backup_files_summary">None</string>
|
||||
<string name="settings_backup_recovery_code">Recovery code</string>
|
||||
<string name="settings_backup_recovery_code_summary">Verify existing code or generate a new one</string>
|
||||
<string name="settings_backup_storage_dialog_title">Experimental feature</string>
|
||||
<string name="settings_backup_storage_dialog_message">Backing up files is still experimental and might not work. Do not rely on it for important data.</string>
|
||||
<string name="settings_backup_storage_dialog_ok">Enable anyway</string>
|
||||
<string name="settings_backup_storage_code_dialog_title">Recovery code verification required</string>
|
||||
<string name="settings_backup_storage_code_dialog_message">To enable storage backup, you need to first verify your recovery code or generate a new one.</string>
|
||||
<string name="settings_backup_storage_code_dialog_ok">Verify code</string>
|
||||
|
||||
<!-- Storage -->
|
||||
<!-- Storage Location -->
|
||||
<string name="storage_fragment_backup_title">Choose where to store backups</string>
|
||||
<string name="storage_fragment_restore_title">Where to find your backups?</string>
|
||||
<string name="storage_fragment_warning">People with access to your storage location can learn which apps you use, but do not get access to the apps\' data.</string>
|
||||
<string name="storage_fragment_warning_delete">Existing backups in this location will be deleted.</string>
|
||||
<string name="storage_fake_drive_title">USB flash drive</string>
|
||||
<string name="storage_fake_drive_summary">Needs to be plugged in</string>
|
||||
<string name="storage_available_bytes"><xliff:g example="1 GB" id="size">%1$s</xliff:g> free</string>
|
||||
<string name="storage_fake_nextcloud_title" translatable="false">Nextcloud</string>
|
||||
<string name="storage_fake_nextcloud_summary">Click to install</string>
|
||||
<string name="storage_fake_nextcloud_summary_installed">Click to set up account</string>
|
||||
<string name="storage_fake_nextcloud_summary">Tap to install</string>
|
||||
<string name="storage_fake_nextcloud_summary_installed">Tap to set up account</string>
|
||||
<string name="storage_fake_nextcloud_summary_unavailable">Account not available. Set one up (or disable passcode).</string>
|
||||
<string name="storage_check_fragment_backup_title">Initializing backup location…</string>
|
||||
<string name="storage_check_fragment_patience">This may take some time…</string>
|
||||
<string name="storage_check_fragment_restore_title">Looking for backups…</string>
|
||||
<string name="storage_check_fragment_backup_error">An error occurred while accessing the backup location.</string>
|
||||
<string name="storage_check_fragment_permission_error">Unable to get the permission to write to the backup location.</string>
|
||||
|
|
@ -69,8 +82,8 @@
|
|||
<string name="recovery_code_input_hint_11">Word 11</string>
|
||||
<string name="recovery_code_input_hint_12">Word 12</string>
|
||||
<string name="recovery_code_error_empty_word">You forgot to enter this word.</string>
|
||||
<string name="recovery_code_error_invalid_word">Wrong word. Did you mean %1$s or %2$s?</string>
|
||||
<string name="recovery_code_error_checksum_word">Your code is invalid. Please check all words and try again!</string>
|
||||
<string name="recovery_code_error_invalid_word">Wrong word.</string>
|
||||
<string name="recovery_code_error_checksum_word">Your code is invalid. Please check all words as well as their position and try again!</string>
|
||||
<string name="recovery_code_verification_ok_title">Recovery code verified</string>
|
||||
<string name="recovery_code_verification_ok_message">Your code is correct and will work for restoring your backup.</string>
|
||||
<string name="recovery_code_verification_error_title">Incorrect recovery code</string>
|
||||
|
|
@ -125,6 +138,7 @@
|
|||
<string name="restore_choose_restore_set">Choose a backup to restore</string>
|
||||
<string name="restore_restore_set_times">Last backup %1$s · First %2$s.</string>
|
||||
<string name="restore_back">Don\'t restore</string>
|
||||
<string name="restore_skip">Skip restoring apps</string>
|
||||
<string name="restore_invalid_location_title">No backups found</string>
|
||||
<string name="restore_invalid_location_message">We could not find any backups at this location.\n\nPlease choose another location that contains a %s folder.</string>
|
||||
<string name="restore_set_error">An error occurred while loading the backups.</string>
|
||||
|
|
@ -141,6 +155,13 @@
|
|||
<string name="restore_finished_success">Restore complete</string>
|
||||
<string name="restore_finished_error">An error occurred while restoring the backup.</string>
|
||||
<string name="restore_finished_button">Finish</string>
|
||||
|
||||
<string name="restore_storage_skip">Skip restoring files</string>
|
||||
<string name="restore_storage_choose_snapshot">Choose a storage backup to restore (experimental)</string>
|
||||
<string name="restore_storage_in_progress_title">Files are being restored…</string>
|
||||
<string name="restore_storage_in_progress_info">Your files are being restored in the background. You can start using your phone while this is running.\n\nSome apps (e.g. Signal or WhatsApp) might require files to be fully restored to import a backup. Try to avoid starting those apps before file restore is not complete.</string>
|
||||
<string name="restore_storage_got_it">Got it</string>
|
||||
|
||||
<string name="storage_internal_warning_title">Warning</string>
|
||||
<string name="storage_internal_warning_message">You have chosen internal storage for your backup. This will not be available when your phone is lost or broken.</string>
|
||||
<string name="storage_internal_warning_choose_other">Choose other</string>
|
||||
|
|
@ -154,6 +175,6 @@
|
|||
<string name="about_author">Written by: <a href="https://github.com/stevesoltys">Steve Soltys</a> and <a href="https://blog.grobox.de">Torsten Grote</a></string>
|
||||
<string name="about_design">Design by: <a href="https://www.glennsorrentino.com/">Glenn Sorrentino</a></string>
|
||||
<string name="about_sponsor">Sponsored by: <a href="https://www.calyxinstitute.org">Calyx Institute</a> for use in <a href="https://calyxos.org">CalyxOS</a></string>
|
||||
<string name="about_source_code">Source Code: https://github.com/seedvault-app/seedvault</string>
|
||||
<string name="about_source_code">Source code: https://github.com/seedvault-app/seedvault</string>
|
||||
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -1,8 +1,21 @@
|
|||
<resources>
|
||||
|
||||
<style name="AppTheme" parent="Theme.AppCompat.DayNight">
|
||||
<style name="AppTheme" parent="@style/Theme.AppCompat.DayNight">
|
||||
<item name="colorPrimary">@color/primary</item>
|
||||
<item name="colorPrimaryDark">@color/primaryDark</item>
|
||||
<item name="colorAccent">@color/accent</item>
|
||||
<item name="colorError">@color/red</item>
|
||||
<item name="android:windowBackground">@color/background</item>
|
||||
<item name="fontFamily">@*android:string/config_bodyFontFamily</item>
|
||||
<item name="preferenceTheme">@style/PreferenceThemeOverlay</item>
|
||||
<item name="android:windowLightStatusBar">@bool/isLight</item>
|
||||
<item name="android:statusBarColor">@color/statusBarColor</item>
|
||||
<item name="actionBarTheme">@style/Theme.ActionBar</item>
|
||||
<item name="android:navigationBarColor">@android:color/transparent</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.ActionBar" parent="Theme.AppCompat.DayNight.DarkActionBar">
|
||||
<item name="colorPrimary">@color/actionBarPrimary</item>
|
||||
</style>
|
||||
|
||||
<style name="AppTheme.NoActionBar" parent="AppTheme">
|
||||
|
|
@ -10,4 +23,7 @@
|
|||
<item name="windowNoTitle">true</item>
|
||||
</style>
|
||||
|
||||
<!-- Copied from Settings -->
|
||||
<style name="ActionPrimaryButton" parent="android:Widget.DeviceDefault.Button.Colored" />
|
||||
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -1,53 +1,75 @@
|
|||
<androidx.preference.PreferenceScreen xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<androidx.preference.SwitchPreferenceCompat
|
||||
app:icon="@drawable/ic_cloud_upload"
|
||||
app:key="backup"
|
||||
app:persistent="false"
|
||||
app:title="@string/settings_backup" />
|
||||
|
||||
<androidx.preference.Preference
|
||||
app:allowDividerAbove="true"
|
||||
app:fragment="com.stevesoltys.seedvault.settings.AppStatusFragment"
|
||||
app:icon="@drawable/ic_apps"
|
||||
app:key="backup_status"
|
||||
app:title="@string/settings_backup_status_title"
|
||||
tools:summary="Last backup: Never" />
|
||||
|
||||
<androidx.preference.Preference
|
||||
app:dependency="backup"
|
||||
app:icon="@drawable/ic_storage"
|
||||
app:icon="@drawable/ic_save_alt"
|
||||
app:key="backup_location"
|
||||
app:summary="@string/settings_backup_location_none"
|
||||
app:title="@string/settings_backup_location" />
|
||||
|
||||
<androidx.preference.SwitchPreferenceCompat
|
||||
app:dependency="backup"
|
||||
app:key="auto_restore"
|
||||
app:persistent="false"
|
||||
app:summary="@string/settings_auto_restore_summary"
|
||||
app:title="@string/settings_auto_restore_title" />
|
||||
|
||||
<androidx.preference.SwitchPreferenceCompat
|
||||
app:defaultValue="true"
|
||||
app:dependency="backup"
|
||||
app:key="backup_apk"
|
||||
app:summary="@string/settings_backup_apk_summary"
|
||||
app:title="@string/settings_backup_apk_title" />
|
||||
|
||||
<androidx.preference.Preference
|
||||
app:dependency="backup"
|
||||
app:fragment="com.stevesoltys.seedvault.ui.recoverycode.RecoveryCodeInputFragment"
|
||||
app:icon="@drawable/ic_vpn_key"
|
||||
app:key="backup_recovery_code"
|
||||
app:summary="@string/settings_backup_recovery_code_summary"
|
||||
app:title="@string/settings_backup_recovery_code" />
|
||||
|
||||
<PreferenceCategory android:title="@string/settings_category_apps">
|
||||
|
||||
<androidx.preference.SwitchPreferenceCompat
|
||||
app:allowDividerBelow="true"
|
||||
app:icon="@drawable/ic_cloud_upload"
|
||||
app:key="backup"
|
||||
app:persistent="false"
|
||||
app:title="@string/settings_backup" />
|
||||
|
||||
<androidx.preference.Preference
|
||||
app:fragment="com.stevesoltys.seedvault.settings.AppStatusFragment"
|
||||
app:icon="@drawable/ic_apps"
|
||||
app:key="backup_status"
|
||||
app:title="@string/settings_backup_status_title"
|
||||
tools:summary="Last backup: Never" />
|
||||
|
||||
<androidx.preference.SwitchPreferenceCompat
|
||||
app:dependency="backup"
|
||||
app:key="auto_restore"
|
||||
app:persistent="false"
|
||||
app:summary="@string/settings_auto_restore_summary"
|
||||
app:title="@string/settings_auto_restore_title"
|
||||
tools:defaultValue="true" />
|
||||
|
||||
<androidx.preference.SwitchPreferenceCompat
|
||||
app:defaultValue="true"
|
||||
app:dependency="backup"
|
||||
app:key="backup_apk"
|
||||
app:summary="@string/settings_backup_apk_summary"
|
||||
app:title="@string/settings_backup_apk_title" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory android:title="@string/settings_category_storage">
|
||||
|
||||
<androidx.preference.SwitchPreferenceCompat
|
||||
app:defaultValue="false"
|
||||
app:icon="@drawable/ic_storage"
|
||||
app:key="backup_storage"
|
||||
app:title="@string/settings_backup_storage_title" />
|
||||
|
||||
<androidx.preference.Preference
|
||||
android:dependency="backup_storage"
|
||||
app:dependency="backup_storage"
|
||||
app:fragment="com.stevesoltys.seedvault.ui.files.FileSelectionFragment"
|
||||
app:icon="@drawable/ic_library_add"
|
||||
app:key="backup_files"
|
||||
app:summary="@string/settings_backup_files_summary"
|
||||
app:title="@string/settings_backup_files_title" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
<androidx.preference.Preference
|
||||
app:allowDividerAbove="true"
|
||||
app:allowDividerBelow="false"
|
||||
app:dependency="backup"
|
||||
app:icon="@drawable/ic_info_outline"
|
||||
app:selectable="false"
|
||||
app:summary="@string/settings_info" />
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ fun ByteArray.toHexString(spacer: String = " "): String {
|
|||
for (b in this) {
|
||||
str += String.format("%02X$spacer", b)
|
||||
}
|
||||
return str
|
||||
return str.trimEnd()
|
||||
}
|
||||
|
||||
fun ByteArray.toIntString(): String {
|
||||
|
|
|
|||
|
|
@ -1,11 +1,10 @@
|
|||
package com.stevesoltys.seedvault.crypto
|
||||
|
||||
import cash.z.ecc.android.bip39.Mnemonics
|
||||
import cash.z.ecc.android.bip39.WordList
|
||||
import cash.z.ecc.android.bip39.toSeed
|
||||
import com.stevesoltys.seedvault.toHexString
|
||||
import io.github.novacrypto.bip39.JavaxPBKDF2WithHmacSHA512
|
||||
import io.github.novacrypto.bip39.MnemonicGenerator
|
||||
import io.github.novacrypto.bip39.SeedCalculator
|
||||
import io.github.novacrypto.bip39.Words
|
||||
import io.github.novacrypto.bip39.wordlists.English
|
||||
import com.stevesoltys.seedvault.ui.recoverycode.toMnemonicChars
|
||||
import org.junit.jupiter.api.Assertions.assertEquals
|
||||
import org.junit.jupiter.api.Assertions.assertTrue
|
||||
import org.junit.jupiter.api.Test
|
||||
|
|
@ -2067,62 +2066,197 @@ class WordListTest {
|
|||
|
||||
@Test
|
||||
fun `word list of library did not change`() {
|
||||
val libWords = WordList().words
|
||||
for (i in words.indices) {
|
||||
assertEquals(words[i], English.INSTANCE.getWord(i))
|
||||
assertEquals(words[i], libWords[i])
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test createMnemonic`() {
|
||||
val entropy = ByteArray(Words.TWELVE.byteLength())
|
||||
fun `test creating MnemonicCode from entropy`() {
|
||||
val entropy = ByteArray(Mnemonics.WordCount.COUNT_12.bitLength / 8)
|
||||
Random.nextBytes(entropy)
|
||||
val list = ArrayList<String>(12)
|
||||
MnemonicGenerator(English.INSTANCE).createMnemonic(entropy) {
|
||||
if (it != " ") list.add(it.toString())
|
||||
}
|
||||
assertEquals(12, list.size)
|
||||
for (word in list) {
|
||||
assertTrue(word in words)
|
||||
val code = Mnemonics.MnemonicCode(entropy)
|
||||
assertEquals(12, code.words.size)
|
||||
for (word in code) {
|
||||
assertTrue(word in words, "$word unknown")
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Suppress("MaxLineLength")
|
||||
fun `12 words generate expected seed`() {
|
||||
fun `12 not validating words generate seed that novacrypt generated`() {
|
||||
assertEquals(
|
||||
"64AA8C388EC0F3A13C7E51653BC766E30668D30952AB34381C4B174BF3278774" +
|
||||
"B4EE43D0BA08BCBCE0D0B806DEB7AA364A83525C34847078B2A8002A3E116066",
|
||||
SeedCalculator(JavaxPBKDF2WithHmacSHA512.INSTANCE).calculateSeed(
|
||||
"write wrong yard year yellow you young youth zebra zero zone zoo", ""
|
||||
).toHexString("")
|
||||
Mnemonics.MnemonicCode(
|
||||
"write wrong yard year yellow you young youth zebra zero zone zoo"
|
||||
).toSeed(validate = false).toHexString("")
|
||||
)
|
||||
assertEquals(
|
||||
"E911FAA42F389AA9F6D5A40B2ECB876B06D6D1FFBD5885C54720398EB11918CA" +
|
||||
"B8F7BAD70FD5BE39BEB4EB065610700D1CFF1D4BFAA26F998357E15E79002779",
|
||||
SeedCalculator(JavaxPBKDF2WithHmacSHA512.INSTANCE).calculateSeed(
|
||||
"matrix lava they brand negative spray floor gym purity picture ritual disorder", ""
|
||||
).toHexString("")
|
||||
Mnemonics.MnemonicCode(
|
||||
"matrix lava they brand negative spray floor gym purity picture ritual disorder"
|
||||
).toSeed(validate = false).toHexString("")
|
||||
)
|
||||
assertEquals(
|
||||
"DDB26091680CF30D0DC615546E4612327DB287B6B2B8B8947A3E12580315D38C" +
|
||||
"3BF7DD0EB4E9E50B10A41925332E0C8ED43C80DBA29281EF331A1DFA858BF1C9",
|
||||
SeedCalculator(JavaxPBKDF2WithHmacSHA512.INSTANCE).calculateSeed(
|
||||
"middle rack south alert ribbon tube hope involve defy oxygen gloom rabbit", ""
|
||||
).toHexString("")
|
||||
Mnemonics.MnemonicCode(
|
||||
"middle rack south alert ribbon tube hope involve defy oxygen gloom rabbit"
|
||||
).toSeed(validate = false).toHexString("")
|
||||
)
|
||||
assertEquals(
|
||||
"4815B580D0DCDA08334C92B3CB9A8436CD581C55841FB2794FB1E3D6E389F447" +
|
||||
"C8C6520B2FE567720950F5B39BE7EC42C0BC98D3C63F8FEF642B5BD3EE4CDD7B",
|
||||
SeedCalculator(JavaxPBKDF2WithHmacSHA512.INSTANCE).calculateSeed(
|
||||
"interest mask trial hold foot segment fade page monitor apple garden shuffle", ""
|
||||
).toHexString("")
|
||||
Mnemonics.MnemonicCode(
|
||||
"interest mask trial hold foot segment fade page monitor apple garden shuffle"
|
||||
).toSeed(validate = false).toHexString("")
|
||||
)
|
||||
assertEquals(
|
||||
"FF462543D8FB9DAE6C17FA7BA047238664207FCC797D6688E10DD1B3CFD183D4" +
|
||||
"928AD088E8287B69BABCAEB0F87A2DFF2ADD49A7FDB7EB2554D7344F09C41A76",
|
||||
SeedCalculator(JavaxPBKDF2WithHmacSHA512.INSTANCE).calculateSeed(
|
||||
"palace glory gospel garment obscure person edge total hunt fix setup uphold\n", ""
|
||||
).toHexString("")
|
||||
Mnemonics.MnemonicCode(
|
||||
"palace glory gospel garment obscure person edge total hunt fix setup uphold\n"
|
||||
).toSeed(validate = false).toHexString("")
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `12 valid words generate seed that novacrypt generated`() {
|
||||
assertEquals(
|
||||
"C6F9762718449C9D0794FEC140D2C8D4E23FF8E3701D64C03DDD13C69BC73E48" +
|
||||
"6AB89AB2C7C9BEA43F4AF839F2078595851D5D48FEC6A9FC6C25F399DBB909F9",
|
||||
Mnemonics.MnemonicCode(
|
||||
"script vault basic album cotton car entire jaguar correct anger select flower"
|
||||
).toSeed().toHexString("")
|
||||
)
|
||||
assertEquals(
|
||||
"13C5188428B1DF8A5333E60BA7EC47F7E75585315C73BD19812D3591C5F4C52B" +
|
||||
"B2FC1FF40B1942E2A1EF9F34F586114ED37D46A5A3907A43B317E937C1D9D2CD",
|
||||
Mnemonics.MnemonicCode(
|
||||
"drastic toy fatal goose treat saddle chalk fame dismiss employ super behind"
|
||||
).toSeed().toHexString("")
|
||||
)
|
||||
assertEquals(
|
||||
"40B41BB22AC3A507F26A78E027A3B3C5C8F45FF0F5593D82762C74AE69FA548B" +
|
||||
"A72C0CED31DED6211884B412E7B80F932F9830FA7A67CDB5B28604213DE6599C",
|
||||
Mnemonics.MnemonicCode(
|
||||
"nation infant heart virus argue two vivid slam lend decorate turn wish"
|
||||
).toSeed().toHexString("")
|
||||
)
|
||||
assertEquals(
|
||||
"B6D755172B6E9353A25EB3559336C17A8619F3EBE55E8A9A74A44E1AB88EF5E2" +
|
||||
"C6E12FE132E42A55CC3F8F9224E6A0ABC9C3FF4EB9523A4E9750CDAAEFBA6282",
|
||||
Mnemonics.MnemonicCode(
|
||||
"elbow boy powder robot eagle rival neutral pigeon oil shrimp demand health"
|
||||
).toSeed().toHexString("")
|
||||
)
|
||||
assertEquals(
|
||||
"3EDB1292B4D124426201AC523FCC2572184E0B63667DA7DF105AD8FCCD16C074" +
|
||||
"C6DAF9C7D644B4B48AF75185D21B9E7D778FFE55F836C539581DEBB98C331526",
|
||||
Mnemonics.MnemonicCode(
|
||||
"build setup screen solution prepare spice organ ten loud seek ask attract"
|
||||
).toSeed().toHexString("")
|
||||
)
|
||||
assertEquals(
|
||||
"65986351CD054822B40E417855AC2B5651C5F87892F17ED2A984F6B59DD5FB4E" +
|
||||
"6A4568ABF7E06D93CBCC69BB68F2625E3E8AF2751106380922D49C0D0D0B456B",
|
||||
Mnemonics.MnemonicCode(
|
||||
"unhappy welcome pizza inflict inherit village minimum orient cheap swear grunt giraffe" // ktlint-disable max-line-length
|
||||
).toSeed().toHexString("")
|
||||
)
|
||||
assertEquals(
|
||||
"639034B381740A9FA5B8A84715CF18B21EBD343DD91F7B6124A0EFC32A636619" +
|
||||
"49B02A7810B1A99D8E8CC4CD7D046CE59EAAADBB52DDC0B5036EFED007E1CFF6",
|
||||
Mnemonics.MnemonicCode(
|
||||
"rather suit pluck afford avocado diary swap library earn song rival fiber"
|
||||
).toSeed().toHexString("")
|
||||
)
|
||||
assertEquals(
|
||||
"43E1417221BFB40851DE286B543B51DEE9C01D239B2C2E8A355D45B3DF95DFAA" +
|
||||
"C8DBCAEF1D864D91759A07057DBDB891900D583CAB09BD0655493912108AE65A",
|
||||
Mnemonics.MnemonicCode(
|
||||
"toss note family morning silk edge high error appear tilt almost myth"
|
||||
).toSeed().toHexString("")
|
||||
)
|
||||
assertEquals(
|
||||
"14084AAF9CFCAC386D4CE5B9140BEADBF727B1B09786A67A574B668A1A4AE0A3" +
|
||||
"21B8D4E7BC005980B088A160B6EC08A1CB892C2090C58D95A7C6AAD16C14EE1E",
|
||||
Mnemonics.MnemonicCode(
|
||||
"parrot burden release bronze section fantasy ridge blood direct physical spoil asthma" // ktlint-disable max-line-length
|
||||
).toSeed().toHexString("")
|
||||
)
|
||||
assertEquals(
|
||||
"E11E8737327EE6A640761B3888C349D829A60FEAEFB7914D2AE1616F0AC45B9A" +
|
||||
"322F41D0030C89E209300FA25615FE6B5BDEF73F3E5CE21167685E8A27EE0790",
|
||||
Mnemonics.MnemonicCode(
|
||||
"version deliver worry sick flee submit pledge adapt night swear glare adult"
|
||||
).toSeed().toHexString("")
|
||||
)
|
||||
assertEquals(
|
||||
"02652896F67695C03F379A354685A8A0B92D0F303F77461476E80BB594EAD84B" +
|
||||
"D00B2943C2229ED843C65F6C53A376005871FF74F834E6B6E3B57FFD83D3FB12",
|
||||
Mnemonics.MnemonicCode(
|
||||
"exercise curtain initial model travel client twist neutral peace unfold start shell" // ktlint-disable max-line-length
|
||||
).toSeed().toHexString("")
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `entropy generates same words that novacrypt generated`() {
|
||||
assertEquals(
|
||||
"B8 3F 0D 49 7F 2A F4 69 13 71 47 D5 54 9D 17 0B",
|
||||
Mnemonics.MnemonicCode(
|
||||
"return wear false wrestle quantum cruel evidence cigar stem pilot easy blood"
|
||||
).toEntropy().toHexString()
|
||||
)
|
||||
assertEquals(
|
||||
"AA 8E 3F 1C EF 60 20 D7 D2 BB FD A0 AA AD 69 09",
|
||||
Mnemonics.MnemonicCode(
|
||||
"pride impose shrimp tell acoustic hip enough leisure pass fever fog basket"
|
||||
).toEntropy().toHexString()
|
||||
)
|
||||
assertEquals(
|
||||
"CE E8 17 7E AB 9E 49 8A 0B 32 3C 97 94 07 0C 32",
|
||||
Mnemonics.MnemonicCode(
|
||||
"solve doll text fire tonight shallow coast elegant nurse parent seek grass"
|
||||
).toEntropy().toHexString()
|
||||
)
|
||||
assertEquals(
|
||||
"AA 27 4B D8 7B 0D 18 EB 5D 08 BD 11 73 36 C1 06",
|
||||
Mnemonics.MnemonicCode(
|
||||
"pretty demise voyage voyage spice interest injury bless badge often raccoon artefact" // ktlint-disable max-line-length
|
||||
).toEntropy().toHexString()
|
||||
)
|
||||
assertEquals(
|
||||
"16 5F A7 40 26 E9 51 70 1B 7A 5C D2 AB CD 73 7E",
|
||||
Mnemonics.MnemonicCode(
|
||||
"bind wood source evidence never retreat hospital entire sport fury fresh woman"
|
||||
).toEntropy().toHexString()
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test create MnemonicCode from List of CharSequence`() {
|
||||
assertEquals(
|
||||
"B8 3F 0D 49 7F 2A F4 69 13 71 47 D5 54 9D 17 0B",
|
||||
Mnemonics.MnemonicCode(
|
||||
listOf<CharSequence>(
|
||||
"return",
|
||||
"wear",
|
||||
"false",
|
||||
"wrestle",
|
||||
"quantum",
|
||||
"cruel",
|
||||
"evidence",
|
||||
"cigar",
|
||||
"stem",
|
||||
"pilot",
|
||||
"easy",
|
||||
"blood"
|
||||
).toMnemonicChars()
|
||||
).toEntropy().toHexString()
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,13 @@
|
|||
package com.stevesoltys.seedvault.plugins.saf
|
||||
|
||||
import android.content.Context
|
||||
import android.content.pm.PackageManager
|
||||
import android.net.Uri
|
||||
import android.provider.DocumentsContract
|
||||
import androidx.documentfile.provider.DocumentFile
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import com.stevesoltys.seedvault.TestApp
|
||||
import io.mockk.every
|
||||
import io.mockk.mockk
|
||||
import org.junit.After
|
||||
import org.junit.Assert.assertEquals
|
||||
|
|
@ -27,6 +29,14 @@ internal class DocumentFileTest {
|
|||
"content://com.android.externalstorage.documents/tree/" +
|
||||
"primary%3A/document/primary%3A.SeedVaultAndroidBackup"
|
||||
)
|
||||
|
||||
init {
|
||||
// needed since 'androidx.documentfile:documentfile:1.0.1'
|
||||
val pm: PackageManager = mockk()
|
||||
every { context.packageManager } returns pm
|
||||
every { pm.queryIntentContentProviders(any(), 0) } returns emptyList()
|
||||
}
|
||||
|
||||
private val parentFile: DocumentFile = DocumentFile.fromTreeUri(context, parentUri)!!
|
||||
private val uri: Uri = Uri.parse(
|
||||
"content://com.android.externalstorage.documents/tree/" +
|
||||
|
|
|
|||
17
build.gradle
17
build.gradle
|
|
@ -1,22 +1,33 @@
|
|||
buildscript {
|
||||
|
||||
// 1.3.21 Android 10
|
||||
// 1.3.61 Android 11
|
||||
// Check:
|
||||
// https://android.googlesource.com/platform/external/kotlinc/+/refs/tags/android-11.0.0_r3/build.txt
|
||||
ext.kotlin_version = '1.3.61'
|
||||
ext.aosp_kotlin_version = '1.3.61'
|
||||
ext.kotlin_version = '1.4.31'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
jcenter()
|
||||
google()
|
||||
}
|
||||
dependencies {
|
||||
//noinspection DifferentKotlinGradleVersion
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
classpath 'com.android.tools.build:gradle:4.1.0'
|
||||
classpath "com.google.protobuf:protobuf-gradle-plugin:0.8.14"
|
||||
classpath 'com.android.tools.build:gradle:4.2.1'
|
||||
}
|
||||
}
|
||||
|
||||
ext {
|
||||
buildToolsVersion = '30.0.2'
|
||||
compileSdkVersion = 30
|
||||
minSdkVersion = 29
|
||||
targetSdkVersion = 30
|
||||
}
|
||||
|
||||
apply from: 'gradle/dependencies.gradle'
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
|
|
|||
|
|
@ -13,11 +13,13 @@ android_app {
|
|||
required: [
|
||||
"default-permissions_org.calyxos.backup.contacts",
|
||||
],
|
||||
product_specific: true,
|
||||
sdk_version: "current",
|
||||
}
|
||||
|
||||
prebuilt_etc {
|
||||
name: "default-permissions_org.calyxos.backup.contacts",
|
||||
product_specific: true,
|
||||
sub_dir: "default-permissions",
|
||||
src: "default-permissions_org.calyxos.backup.contacts.xml",
|
||||
filename_from_src: true,
|
||||
|
|
|
|||
|
|
@ -50,16 +50,12 @@ def aospDeps = fileTree(include: [
|
|||
dependencies {
|
||||
implementation aospDeps
|
||||
|
||||
//noinspection GradleDependency
|
||||
testImplementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
|
||||
testImplementation 'junit:junit:4.13.1'
|
||||
def mockk_version = "1.10.2"
|
||||
testImplementation "junit:junit:$junit4_version"
|
||||
testImplementation "io.mockk:mockk:$mockk_version"
|
||||
|
||||
//noinspection GradleDependency
|
||||
androidTestImplementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
|
||||
def espresso_version = "3.3.0"
|
||||
androidTestImplementation "androidx.test.espresso:espresso-core:$espresso_version"
|
||||
androidTestImplementation "io.mockk:mockk-android:$mockk_version"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
package="org.calyxos.backup.contacts"
|
||||
android:versionCode="30000011"
|
||||
android:versionName="11-1.1">
|
||||
android:versionCode="30000211"
|
||||
android:versionName="11-2.1">
|
||||
<!--
|
||||
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.
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
org.gradle.jvmargs=-Xmx1g
|
||||
org.gradle.configureondemand=true
|
||||
android.useAndroidX=true
|
||||
android.enableJetifier=false
|
||||
kotlin.code.style=official
|
||||
|
|
|
|||
|
|
@ -1,130 +1,101 @@
|
|||
ext {
|
||||
// https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-11.0.0_r3/current/androidx/Android.bp#2713
|
||||
ext.room_version = "2.3.0-alpha02"
|
||||
// http://aosp.opersys.com/xref/android-11.0.0_r27/xref/external/protobuf/java/pom.xml#7
|
||||
ext.protobuf_version = "3.9.1"
|
||||
junit4_version = "4.13.2"
|
||||
junit5_version = "5.5.2" // careful, upgrading this can change a Cipher's IV size in tests!?
|
||||
mockk_version = "1.10.2" // higher versions get us a kotlin version conflict
|
||||
espresso_version = "3.3.0"
|
||||
}
|
||||
|
||||
// To produce these binaries, in latest AOSP source tree, run
|
||||
// $ m
|
||||
def aospDeps = fileTree(include: [
|
||||
// For more information about this module:
|
||||
// https://android.googlesource.com/platform/frameworks/base/+/refs/tags/android-11.0.0_r3/Android.bp#507
|
||||
// framework_intermediates/classes-header.jar works for gradle build as well,
|
||||
// but not unit tests, so we use the actual classes (without updatable modules).
|
||||
//
|
||||
// out/target/common/obj/JAVA_LIBRARIES/framework-minus-apex_intermediates/classes.jar
|
||||
'android.jar',
|
||||
// out/target/common/obj/JAVA_LIBRARIES/core-libart.com.android.art.release_intermediates/classes.jar
|
||||
'libcore.jar'
|
||||
], dir: 'libs')
|
||||
ext.aosp_libs = fileTree(include: [
|
||||
// For more information about this module:
|
||||
// https://android.googlesource.com/platform/frameworks/base/+/refs/tags/android-11.0.0_r3/Android.bp#507
|
||||
// framework_intermediates/classes-header.jar works for gradle build as well,
|
||||
// but not unit tests, so we use the actual classes (without updatable modules).
|
||||
//
|
||||
// out/target/common/obj/JAVA_LIBRARIES/framework-minus-apex_intermediates/classes.jar
|
||||
'android.jar',
|
||||
// out/target/common/obj/JAVA_LIBRARIES/core-libart.com.android.art.release_intermediates/classes.jar
|
||||
'libcore.jar',
|
||||
], dir: "$projectDir/app/libs")
|
||||
|
||||
dependencies {
|
||||
compileOnly aospDeps
|
||||
ext.kotlin_libs = [
|
||||
std: [
|
||||
dependencies.create('org.jetbrains.kotlin:kotlin-stdlib') {
|
||||
version { strictly "$aosp_kotlin_version" }
|
||||
},
|
||||
dependencies.create('org.jetbrains.kotlin:kotlin-stdlib-jdk8') {
|
||||
version { strictly "$aosp_kotlin_version" }
|
||||
},
|
||||
dependencies.create('org.jetbrains.kotlin:kotlin-stdlib-common') {
|
||||
version { strictly "$aosp_kotlin_version" }
|
||||
},
|
||||
],
|
||||
coroutines: [
|
||||
dependencies.create('org.jetbrains.kotlinx:kotlinx-coroutines-core') {
|
||||
// https://android.googlesource.com/platform/prebuilts/tools/+/refs/tags/android-11.0.0_r3/common/m2/Android.bp#326
|
||||
version { strictly '1.3.0' }
|
||||
},
|
||||
dependencies.create('org.jetbrains.kotlinx:kotlinx-coroutines-android') {
|
||||
// https://android.googlesource.com/platform/prebuilts/tools/+/refs/tags/android-11.0.0_r3/common/m2/Android.bp#340
|
||||
version { strictly '1.3.0' }
|
||||
},
|
||||
],
|
||||
]
|
||||
|
||||
/**
|
||||
* 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('org.jetbrains.kotlin:kotlin-stdlib-jdk8') {
|
||||
version { strictly "$kotlin_version" }
|
||||
}
|
||||
implementation('org.jetbrains.kotlin:kotlin-stdlib-common') {
|
||||
version { strictly "$kotlin_version" }
|
||||
}
|
||||
implementation('org.jetbrains.kotlin:kotlin-stdlib') {
|
||||
version { strictly "$kotlin_version" }
|
||||
}
|
||||
|
||||
// These coroutine libraries get upgraded otherwise to versions incompatible with kotlin version
|
||||
implementation('org.jetbrains.kotlinx:kotlinx-coroutines-core') {
|
||||
// https://android.googlesource.com/platform/prebuilts/tools/+/refs/tags/android-11.0.0_r3/common/m2/Android.bp#326
|
||||
version { strictly '1.3.0' }
|
||||
}
|
||||
implementation('org.jetbrains.kotlinx:kotlinx-coroutines-android') {
|
||||
// https://android.googlesource.com/platform/prebuilts/tools/+/refs/tags/android-11.0.0_r3/common/m2/Android.bp#340
|
||||
version { strictly '1.3.0' }
|
||||
}
|
||||
|
||||
implementation('androidx.core:core-ktx') {
|
||||
// https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-11.0.0_r3/current/androidx/Android.bp#610
|
||||
ext.std_libs = [
|
||||
// https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-11.0.0_r3/current/androidx/Android.bp#610
|
||||
androidx_core: dependencies.create('androidx.core:core-ktx') {
|
||||
version { strictly '1.5.0-alpha01' }
|
||||
}
|
||||
|
||||
// A newer version gets pulled in with AOSP via core, so we include this here explicitly
|
||||
implementation('androidx.fragment:fragment-ktx') {
|
||||
// https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-11.0.0_r3/current/androidx/Android.bp#930
|
||||
},
|
||||
// https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-11.0.0_r3/current/androidx/Android.bp#930
|
||||
androidx_fragment: dependencies.create('androidx.fragment:fragment-ktx') {
|
||||
version { strictly '1.3.0-alpha07' }
|
||||
}
|
||||
|
||||
implementation('androidx.preference:preference') {
|
||||
// https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-11.0.0_r3/current/androidx/Android.bp#2412
|
||||
},
|
||||
// https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-11.0.0_r3/current/androidx/Android.bp#2412
|
||||
androidx_preference: dependencies.create('androidx.preference:preference') {
|
||||
version { strictly '1.1.1' } // should be 1.2.0-alpha01, but that is not even released, yet
|
||||
}
|
||||
|
||||
implementation('androidx.lifecycle:lifecycle-viewmodel-ktx') {
|
||||
// https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-11.0.0_r3/current/androidx/Android.bp#1553
|
||||
},
|
||||
// https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-11.0.0_r3/current/androidx/Android.bp#1553
|
||||
androidx_lifecycle_viewmodel_ktx: dependencies.create('androidx.lifecycle:lifecycle-viewmodel-ktx') {
|
||||
version { strictly '2.3.0-alpha05' }
|
||||
}
|
||||
|
||||
implementation('androidx.lifecycle:lifecycle-livedata-ktx') {
|
||||
// https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-11.0.0_r3/current/androidx/Android.bp#1353
|
||||
},
|
||||
// https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-11.0.0_r3/current/androidx/Android.bp#1353
|
||||
androidx_lifecycle_livedata_ktx: dependencies.create('androidx.lifecycle:lifecycle-livedata-ktx') {
|
||||
version { strictly '2.3.0-alpha05' }
|
||||
}
|
||||
|
||||
implementation('androidx.constraintlayout:constraintlayout') {
|
||||
// https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-11.0.0_r3/current/extras/constraint-layout-x/Android.bp#30
|
||||
},
|
||||
// https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-11.0.0_r3/current/extras/constraint-layout-x/Android.bp#30
|
||||
androidx_constraintlayout: dependencies.create('androidx.constraintlayout:constraintlayout') {
|
||||
version { strictly '2.0.0-beta7' }
|
||||
}
|
||||
|
||||
implementation('com.google.android.material:material') {
|
||||
// https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-11.0.0_r3/current/extras/material-design-x/Android.bp#6
|
||||
},
|
||||
// https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-11.0.0_r3/current/androidx/Android.bp#708
|
||||
androidx_documentfile: dependencies.create('androidx.documentfile:documentfile') {
|
||||
version { strictly '1.0.1' } // should be 1.1.0-alpha01, but that is not even released, yet
|
||||
},
|
||||
// https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-11.0.0_r3/current/extras/material-design-x/Android.bp#6
|
||||
com_google_android_material: dependencies.create('com.google.android.material:material') {
|
||||
version { strictly '1.1.0-alpha05' }
|
||||
}
|
||||
},
|
||||
]
|
||||
|
||||
ext.lint_libs = [
|
||||
exceptions: 'com.github.thirdegg:lint-rules:0.0.6-beta'
|
||||
]
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
|
||||
def koin_version = '2.1.1' // later versions require newer kotlin version
|
||||
//noinspection GradleDependency
|
||||
implementation("org.koin:koin-android:$koin_version") {
|
||||
exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib'
|
||||
}
|
||||
//noinspection GradleDependency
|
||||
implementation("org.koin:koin-androidx-viewmodel:$koin_version") {
|
||||
exclude group: 'org.koin', module: 'koin-androidx-scope'
|
||||
exclude group: 'androidx.lifecycle'
|
||||
}
|
||||
|
||||
implementation('io.github.novacrypto:BIP39:2019.01.27') {
|
||||
exclude group: 'com.madgag.spongycastle'
|
||||
}
|
||||
|
||||
/**
|
||||
* Test Dependencies (do not concern the AOSP build)
|
||||
*/
|
||||
|
||||
lintChecks 'com.github.thirdegg:lint-rules:0.0.5-alpha'
|
||||
|
||||
def junit_version = "5.5.2" // careful, upgrading this can change a Cipher's IV size in tests!?
|
||||
def mockk_version = "1.10.0"
|
||||
testImplementation aospDeps // anything less than 'implementation' fails tests run with gradlew
|
||||
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:$junit_version"
|
||||
testImplementation "io.mockk:mockk:$mockk_version"
|
||||
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junit_version"
|
||||
testRuntimeOnly "org.junit.vintage:junit-vintage-engine:$junit_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"
|
||||
}
|
||||
ext.storage_libs = [
|
||||
// https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-11.0.0_r3/current/androidx/Android.bp#2711
|
||||
androidx_room_runtime: dependencies.create('androidx.room:room-runtime') {
|
||||
version { strictly "$room_version" }
|
||||
},
|
||||
// http://aosp.opersys.com/xref/android-11.0.0_r27/xref/external/protobuf/java/pom.xml#7
|
||||
com_google_protobuf_javalite: dependencies.create('com.google.protobuf:protobuf-javalite') {
|
||||
version { strictly "$protobuf_version" }
|
||||
},
|
||||
com_google_crypto_tink_android: dependencies.create('com.google.crypto.tink:tink-android') {
|
||||
version { strictly '1.5.0' }
|
||||
},
|
||||
]
|
||||
|
|
|
|||
11
gradle/ktlint.gradle
Normal file
11
gradle/ktlint.gradle
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
ktlint {
|
||||
version = "0.40.0"
|
||||
android = true
|
||||
enableExperimentalRules = false
|
||||
verbose = true
|
||||
disabledRules = [
|
||||
"import-ordering",
|
||||
"no-blank-line-before-rbrace",
|
||||
"indent", // remove in 0.41 https://github.com/pinterest/ktlint/issues/764
|
||||
]
|
||||
}
|
||||
4
gradle/wrapper/gradle-wrapper.properties
vendored
4
gradle/wrapper/gradle-wrapper.properties
vendored
|
|
@ -3,5 +3,5 @@ distributionBase=GRADLE_USER_HOME
|
|||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-all.zip
|
||||
distributionSha256Sum=143a28f54f1ae93ef4f72d862dbc3c438050d81bb45b4601eb7076e998362920
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip
|
||||
distributionSha256Sum=22449f5231796abd892c98b2a07c9ceebe4688d192cd2d6763f8e3bf8acbedeb
|
||||
|
|
|
|||
5
libs/Android.bp
Normal file
5
libs/Android.bp
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
java_import {
|
||||
name: "seedvault-lib-kotlin-bip39",
|
||||
jars: ["kotlin-bip39-1.0.2.jar"],
|
||||
sdk_version: "current",
|
||||
}
|
||||
BIN
libs/kotlin-bip39-1.0.2.jar
Normal file
BIN
libs/kotlin-bip39-1.0.2.jar
Normal file
Binary file not shown.
|
|
@ -1,27 +0,0 @@
|
|||
java_import {
|
||||
name: "seedvault-lib-novacrypto-bip39-nodeps",
|
||||
jars: ["BIP39-2019.01.27.jar"],
|
||||
sdk_version: "current",
|
||||
}
|
||||
|
||||
java_library_static {
|
||||
name: "seedvault-lib-novacrypto-bip39",
|
||||
static_libs: [
|
||||
"seedvault-lib-novacrypto-bip39-nodeps",
|
||||
"seedvault-lib-novacrypto-sha256",
|
||||
"seedvault-lib-novacrypto-toruntime",
|
||||
],
|
||||
sdk_version: "current",
|
||||
}
|
||||
|
||||
java_import {
|
||||
name: "seedvault-lib-novacrypto-sha256",
|
||||
jars: ["SHA256-2019.01.27.jar"],
|
||||
sdk_version: "current",
|
||||
}
|
||||
|
||||
java_import {
|
||||
name: "seedvault-lib-novacrypto-toruntime",
|
||||
jars: ["ToRuntime-0.9.0.jar"],
|
||||
sdk_version: "current",
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -5,5 +5,6 @@
|
|||
<permission name="android.permission.MANAGE_USB"/>
|
||||
<permission name="android.permission.INSTALL_PACKAGES"/>
|
||||
<permission name="android.permission.WRITE_SECURE_SETTINGS"/>
|
||||
<permission name="android.permission.MANAGE_EXTERNAL_STORAGE"/>
|
||||
</privapp-permissions>
|
||||
</permissions>
|
||||
|
|
@ -1,2 +1,4 @@
|
|||
include ':app'
|
||||
include ':contactsbackup'
|
||||
include ':storage:lib'
|
||||
include ':storage:demo'
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue