Add initial sms exporter integration behind a feature flag.

This commit is contained in:
Alex Hart
2022-08-30 15:22:40 -03:00
committed by Greyson Parrelli
parent 1cc39fb89b
commit 936212e684
40 changed files with 1218 additions and 75 deletions

View File

@@ -70,7 +70,7 @@ class MainActivity : AppCompatActivity(R.layout.main_activity) {
DefaultSmsHelper.releaseDefaultSms(this).either(
onFailure = {
when (it) {
ReleaseSmsAppFailure.APP_IS_INELIGABLE_TO_RELEASE_SMS_SELECTION -> onAppIsIneligableForReleaseSmsSelection()
ReleaseSmsAppFailure.APP_IS_INELIGIBLE_TO_RELEASE_SMS_SELECTION -> onAppIsIneligibleForReleaseSmsSelection()
ReleaseSmsAppFailure.NO_METHOD_TO_RELEASE_SMS_AVIALABLE -> onNoMethodToReleaseSmsAvailable()
}
},
@@ -126,7 +126,7 @@ class MainActivity : AppCompatActivity(R.layout.main_activity) {
startActivityForResult(intent, 2)
}
private fun onAppIsIneligableForReleaseSmsSelection() {
private fun onAppIsIneligibleForReleaseSmsSelection() {
if (!DefaultSmsHelper.isDefaultSms(this)) {
Toast.makeText(this, "Already not the SMS manager.", Toast.LENGTH_SHORT).show()
} else {

View File

@@ -8,6 +8,7 @@ import org.signal.smsexporter.ExportableMessage
import org.signal.smsexporter.SmsExportService
import org.signal.smsexporter.SmsExportState
import java.io.InputStream
import kotlin.time.Duration.Companion.seconds
class TestSmsExportService : SmsExportService() {
@@ -32,10 +33,6 @@ class TestSmsExportService : SmsExportService() {
)
}
override fun getExportState(exportableMessage: ExportableMessage): SmsExportState {
return SmsExportState()
}
override fun getUnexportedMessageCount(): Int {
return 50
}
@@ -92,10 +89,6 @@ class TestSmsExportService : SmsExportService() {
return BitmapGenerator.getStream()
}
override fun onAttachmentWrittenToDisk(exportableMessage: ExportableMessage, part: ExportableMessage.Mms.Part) {
Log.d(TAG, "onAttachmentWrittenToDisk() called with: exportableMessage = $exportableMessage, attachment = $part")
}
override fun onExportPassCompleted() {
Log.d(TAG, "onExportPassCompleted() called")
}
@@ -137,9 +130,10 @@ class TestSmsExportService : SmsExportService() {
val address = addresses.random()
return ExportableMessage.Mms(
id = "$it",
exportState = SmsExportState(),
addresses = addresses,
dateSent = startTime + it - 1,
dateReceived = startTime + it,
dateSent = (startTime + it - 1).seconds,
dateReceived = (startTime + it).seconds,
isRead = true,
isOutgoing = address == me,
sender = address,
@@ -153,10 +147,11 @@ class TestSmsExportService : SmsExportService() {
private fun getSmsMessage(it: Int): ExportableMessage.Sms {
return ExportableMessage.Sms(
id = it.toString(),
exportState = SmsExportState(),
address = "+15065550102",
body = "Hello, World! $it",
dateSent = startTime + it - 1,
dateReceived = startTime + it,
dateSent = (startTime + it - 1).seconds,
dateReceived = (startTime + it).seconds,
isRead = true,
isOutgoing = it % 4 == 0
)