mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-23 20:48:43 +00:00
Improve ABS logging.
This commit is contained in:
committed by
Cody Henthorne
parent
4b446877af
commit
500a1e46ad
@@ -21,6 +21,7 @@ class SignalBackupAgent : BackupAgent() {
|
|||||||
)
|
)
|
||||||
|
|
||||||
override fun onBackup(oldState: ParcelFileDescriptor?, data: BackupDataOutput, newState: ParcelFileDescriptor) {
|
override fun onBackup(oldState: ParcelFileDescriptor?, data: BackupDataOutput, newState: ParcelFileDescriptor) {
|
||||||
|
Log.i(TAG, "Performing backup to Android Backup Service.")
|
||||||
val contentsHash = cumulativeHashCode()
|
val contentsHash = cumulativeHashCode()
|
||||||
if (oldState == null) {
|
if (oldState == null) {
|
||||||
performBackup(data)
|
performBackup(data)
|
||||||
@@ -36,9 +37,11 @@ class SignalBackupAgent : BackupAgent() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
DataOutputStream(FileOutputStream(newState.fileDescriptor)).use { it.writeInt(contentsHash) }
|
DataOutputStream(FileOutputStream(newState.fileDescriptor)).use { it.writeInt(contentsHash) }
|
||||||
|
Log.i(TAG, "Backup finished.")
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun performBackup(data: BackupDataOutput) {
|
private fun performBackup(data: BackupDataOutput) {
|
||||||
|
Log.i(TAG, "Creating new backup data.")
|
||||||
items.forEach {
|
items.forEach {
|
||||||
val backupData = it.getDataForBackup()
|
val backupData = it.getDataForBackup()
|
||||||
data.writeEntityHeader(it.getKey(), backupData.size)
|
data.writeEntityHeader(it.getKey(), backupData.size)
|
||||||
@@ -54,7 +57,7 @@ class SignalBackupAgent : BackupAgent() {
|
|||||||
items.find { dataInput.key == it.getKey() }?.restoreData(buffer)
|
items.find { dataInput.key == it.getKey() }?.restoreData(buffer)
|
||||||
}
|
}
|
||||||
DataOutputStream(FileOutputStream(newState.fileDescriptor)).use { it.writeInt(cumulativeHashCode()) }
|
DataOutputStream(FileOutputStream(newState.fileDescriptor)).use { it.writeInt(cumulativeHashCode()) }
|
||||||
Log.i(TAG, "Android Backup Service complete.")
|
Log.i(TAG, "Android Backup Service restore complete.")
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun cumulativeHashCode(): Int {
|
private fun cumulativeHashCode(): Int {
|
||||||
@@ -62,6 +65,6 @@ class SignalBackupAgent : BackupAgent() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private const val TAG = "SignalBackupAgent"
|
private val TAG = Log.tag(SignalBackupAgent::class)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user