-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Add SCHEDULE_EXACT_ALARM permission - Add FLAG_IMMUTABLE to PendingIntents
- Loading branch information
Tobias Länge
committed
Oct 27, 2022
1 parent
74e315b
commit 8d562dd
Showing
19 changed files
with
382 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "libs/privacy-friendly-backup-api"] | ||
path = libs/privacy-friendly-backup-api | ||
url = https://github.com/SecUSo/privacy-friendly-backup-api.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
app/src/main/java/org/secuso/privacyfriendlycircuittraining/PFCircuitTrainingApplication.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package org.secuso.privacyfriendlycircuittraining | ||
|
||
import android.app.Application | ||
import android.util.Log | ||
import androidx.work.Configuration | ||
import org.secuso.privacyfriendlybackup.api.pfa.BackupManager | ||
import org.secuso.privacyfriendlycircuittraining.backup.BackupCreator | ||
import org.secuso.privacyfriendlycircuittraining.backup.BackupRestorer | ||
|
||
class PFCircuitTrainingApplication : Application(), Configuration.Provider { | ||
|
||
override fun onCreate() { | ||
super.onCreate() | ||
BackupManager.backupCreator = BackupCreator() | ||
BackupManager.backupRestorer = BackupRestorer() | ||
} | ||
|
||
override fun getWorkManagerConfiguration(): Configuration { | ||
return Configuration.Builder().setMinimumLoggingLevel(Log.INFO).build() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
app/src/main/java/org/secuso/privacyfriendlycircuittraining/backup/BackupCreator.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package org.secuso.privacyfriendlycircuittraining.backup | ||
|
||
import android.content.Context | ||
import android.preference.PreferenceManager | ||
import android.util.JsonWriter | ||
import android.util.Log | ||
import org.secuso.privacyfriendlybackup.api.backup.DatabaseUtil.getSupportSQLiteOpenHelper | ||
import org.secuso.privacyfriendlybackup.api.backup.DatabaseUtil.writeDatabase | ||
import org.secuso.privacyfriendlybackup.api.backup.PreferenceUtil.writePreferences | ||
import org.secuso.privacyfriendlybackup.api.pfa.IBackupCreator | ||
import org.secuso.privacyfriendlycircuittraining.database.PFASQLiteHelper | ||
import java.io.OutputStream | ||
import java.io.OutputStreamWriter | ||
|
||
class BackupCreator : IBackupCreator { | ||
override fun writeBackup(context: Context, outputStream: OutputStream): Boolean { | ||
Log.d(TAG, "createBackup() started") | ||
val outputStreamWriter = OutputStreamWriter(outputStream, Charsets.UTF_8) | ||
val writer = JsonWriter(outputStreamWriter) | ||
writer.setIndent("") | ||
|
||
try { | ||
writer.beginObject() | ||
|
||
Log.d(TAG, "Writing database") | ||
writer.name("database") | ||
|
||
val database = getSupportSQLiteOpenHelper(context, PFASQLiteHelper.DATABASE_NAME).readableDatabase | ||
|
||
writeDatabase(writer, database) | ||
database.close() | ||
|
||
Log.d(TAG, "Writing preferences") | ||
writer.name("preferences") | ||
|
||
val pref = PreferenceManager.getDefaultSharedPreferences(context.applicationContext) | ||
writePreferences(writer, pref) | ||
|
||
writer.endObject() | ||
writer.close() | ||
} catch (e: Exception) { | ||
Log.e(TAG, "Error occurred", e) | ||
e.printStackTrace() | ||
return false | ||
} | ||
|
||
Log.d(TAG, "Backup created successfully") | ||
return true | ||
} | ||
|
||
companion object { | ||
const val TAG = "PFABackupCreator" | ||
} | ||
} |
Oops, something went wrong.