mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-22 20:18:36 +00:00
Allow for larger input videos for sending.
This commit is contained in:
committed by
Greyson Parrelli
parent
58443c46be
commit
6daee5719b
@@ -62,7 +62,7 @@ public class PushMediaConstraints extends MediaConstraints {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getUncompressedVideoMaxSize(Context context) {
|
public long getUncompressedVideoMaxSize(Context context) {
|
||||||
return isVideoTranscodeAvailable() ? 500 * MB
|
return isVideoTranscodeAvailable() ? RemoteConfig.maxSourceTranscodeVideoSizeBytes()
|
||||||
: getVideoMaxSize(context);
|
: getVideoMaxSize(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
|
|||||||
import io.reactivex.rxjava3.kotlin.subscribeBy
|
import io.reactivex.rxjava3.kotlin.subscribeBy
|
||||||
import org.signal.core.util.Result
|
import org.signal.core.util.Result
|
||||||
import org.signal.core.util.concurrent.LifecycleDisposable
|
import org.signal.core.util.concurrent.LifecycleDisposable
|
||||||
|
import org.signal.core.util.concurrent.addTo
|
||||||
import org.signal.core.util.getParcelableArrayListCompat
|
import org.signal.core.util.getParcelableArrayListCompat
|
||||||
import org.signal.core.util.getParcelableArrayListExtraCompat
|
import org.signal.core.util.getParcelableArrayListExtraCompat
|
||||||
import org.signal.core.util.getParcelableExtraCompat
|
import org.signal.core.util.getParcelableExtraCompat
|
||||||
@@ -25,6 +26,7 @@ import org.signal.core.util.logging.Log
|
|||||||
import org.thoughtcrime.securesms.MainActivity
|
import org.thoughtcrime.securesms.MainActivity
|
||||||
import org.thoughtcrime.securesms.PassphraseRequiredActivity
|
import org.thoughtcrime.securesms.PassphraseRequiredActivity
|
||||||
import org.thoughtcrime.securesms.R
|
import org.thoughtcrime.securesms.R
|
||||||
|
import org.thoughtcrime.securesms.components.SignalProgressDialog
|
||||||
import org.thoughtcrime.securesms.contacts.paged.ContactSearchKey
|
import org.thoughtcrime.securesms.contacts.paged.ContactSearchKey
|
||||||
import org.thoughtcrime.securesms.conversation.ConversationIntents
|
import org.thoughtcrime.securesms.conversation.ConversationIntents
|
||||||
import org.thoughtcrime.securesms.conversation.MessageSendType
|
import org.thoughtcrime.securesms.conversation.MessageSendType
|
||||||
@@ -42,6 +44,7 @@ import org.thoughtcrime.securesms.util.ConversationUtil
|
|||||||
import org.thoughtcrime.securesms.util.DynamicNoActionBarTheme
|
import org.thoughtcrime.securesms.util.DynamicNoActionBarTheme
|
||||||
import org.thoughtcrime.securesms.util.visible
|
import org.thoughtcrime.securesms.util.visible
|
||||||
import java.util.Optional
|
import java.util.Optional
|
||||||
|
import java.util.concurrent.TimeUnit
|
||||||
|
|
||||||
class ShareActivity : PassphraseRequiredActivity(), MultiselectForwardFragment.Callback {
|
class ShareActivity : PassphraseRequiredActivity(), MultiselectForwardFragment.Callback {
|
||||||
|
|
||||||
@@ -123,6 +126,22 @@ class ShareActivity : PassphraseRequiredActivity(), MultiselectForwardFragment.C
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var dialog: SignalProgressDialog? = null
|
||||||
|
viewModel
|
||||||
|
.state
|
||||||
|
.debounce(500, TimeUnit.MILLISECONDS)
|
||||||
|
.onErrorComplete()
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribeBy { state ->
|
||||||
|
if (state.loadState == ShareState.ShareDataLoadState.Init) {
|
||||||
|
dialog = SignalProgressDialog.show(this, indeterminate = true)
|
||||||
|
} else {
|
||||||
|
dialog?.dismiss()
|
||||||
|
dialog = null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.addTo(lifecycleDisposable)
|
||||||
|
|
||||||
lifecycleDisposable += viewModel.state.observeOn(AndroidSchedulers.mainThread()).subscribe { shareState ->
|
lifecycleDisposable += viewModel.state.observeOn(AndroidSchedulers.mainThread()).subscribe { shareState ->
|
||||||
when (shareState.loadState) {
|
when (shareState.loadState) {
|
||||||
ShareState.ShareDataLoadState.Init -> Unit
|
ShareState.ShareDataLoadState.Init -> Unit
|
||||||
|
|||||||
@@ -869,6 +869,15 @@ object RemoteConfig {
|
|||||||
hotSwappable = true
|
hotSwappable = true
|
||||||
)
|
)
|
||||||
|
|
||||||
|
/** Maximum input size when opening a video to send in bytes */
|
||||||
|
@JvmStatic
|
||||||
|
@get:JvmName("maxSourceTranscodeVideoSizeBytes")
|
||||||
|
val maxSourceTranscodeVideoSizeBytes: Long by remoteLong(
|
||||||
|
key = "android.media.sourceTranscodeVideo.maxBytes",
|
||||||
|
defaultValue = 500L.mebiBytes.inWholeBytes,
|
||||||
|
hotSwappable = true
|
||||||
|
)
|
||||||
|
|
||||||
const val PROMPT_FOR_NOTIFICATION_LOGS: String = "android.logs.promptNotifications"
|
const val PROMPT_FOR_NOTIFICATION_LOGS: String = "android.logs.promptNotifications"
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ public abstract class DigestingOutputStream extends FilterOutputStream {
|
|||||||
private final MessageDigest runningDigest;
|
private final MessageDigest runningDigest;
|
||||||
|
|
||||||
private byte[] digest;
|
private byte[] digest;
|
||||||
|
private long totalBytesWritten = 0;
|
||||||
|
|
||||||
public DigestingOutputStream(OutputStream outputStream) {
|
public DigestingOutputStream(OutputStream outputStream) {
|
||||||
super(outputStream);
|
super(outputStream);
|
||||||
@@ -27,16 +28,19 @@ public abstract class DigestingOutputStream extends FilterOutputStream {
|
|||||||
public void write(byte[] buffer) throws IOException {
|
public void write(byte[] buffer) throws IOException {
|
||||||
runningDigest.update(buffer, 0, buffer.length);
|
runningDigest.update(buffer, 0, buffer.length);
|
||||||
out.write(buffer, 0, buffer.length);
|
out.write(buffer, 0, buffer.length);
|
||||||
|
totalBytesWritten += buffer.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void write(byte[] buffer, int offset, int length) throws IOException {
|
public void write(byte[] buffer, int offset, int length) throws IOException {
|
||||||
runningDigest.update(buffer, offset, length);
|
runningDigest.update(buffer, offset, length);
|
||||||
out.write(buffer, offset, length);
|
out.write(buffer, offset, length);
|
||||||
|
totalBytesWritten += length;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void write(int b) throws IOException {
|
public void write(int b) throws IOException {
|
||||||
runningDigest.update((byte)b);
|
runningDigest.update((byte)b);
|
||||||
out.write(b);
|
out.write(b);
|
||||||
|
totalBytesWritten++;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void flush() throws IOException {
|
public void flush() throws IOException {
|
||||||
@@ -52,4 +56,7 @@ public abstract class DigestingOutputStream extends FilterOutputStream {
|
|||||||
return digest;
|
return digest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public long getTotalBytesWritten() {
|
||||||
|
return totalBytesWritten;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,22 +52,20 @@ class DigestingRequestBody(
|
|||||||
|
|
||||||
val buffer = ByteArray(8192)
|
val buffer = ByteArray(8192)
|
||||||
var read: Int
|
var read: Int
|
||||||
var total: Long = 0
|
|
||||||
|
|
||||||
while (inputStream.read(buffer, 0, buffer.size).also { read = it } != -1) {
|
while (inputStream.read(buffer, 0, buffer.size).also { read = it } != -1) {
|
||||||
if (cancelationSignal?.isCanceled == true) {
|
if (cancelationSignal?.isCanceled == true) {
|
||||||
throw IOException("Canceled!")
|
throw IOException("Canceled!")
|
||||||
}
|
}
|
||||||
outputStream.write(buffer, 0, read)
|
outputStream.write(buffer, 0, read)
|
||||||
total += read.toLong()
|
progressListener?.onAttachmentProgress(contentLength, outputStream.totalBytesWritten)
|
||||||
progressListener?.onAttachmentProgress(contentLength, total)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
outputStream.flush()
|
outputStream.flush()
|
||||||
|
|
||||||
val incrementalDigest: ByteArray = if (isIncremental) {
|
val incrementalDigest: ByteArray = if (isIncremental) {
|
||||||
if (contentLength != total) {
|
if (contentLength != outputStream.totalBytesWritten) {
|
||||||
Log.w(TAG, "Content uploaded ${logMessage(total, contentLength)} bytes compared to expected!")
|
Log.w(TAG, "Content uploaded ${logMessage(outputStream.totalBytesWritten, contentLength)} bytes compared to expected!")
|
||||||
} else {
|
} else {
|
||||||
Log.d(TAG, "Wrote the expected number of bytes.")
|
Log.d(TAG, "Wrote the expected number of bytes.")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user