1) Remove all our PDU code and switch to the PDU code from the klinker library 2) Switch to using the system Lollipop MMS library by default, and falling back to our own custom library if that fails. 3) Format SMIL differently, using code from klinker instead of what we've pieced together. 4) Pull per-carrier MMS media constraints from the XML config files in the klinker library, instead of hardcoding it at 280kb. Hopefully this is an improvement, but given that MMS is involved, it will probably make things worse instead.
78 lines
2 KiB
Java
78 lines
2 KiB
Java
package org.thoughtcrime.securesms.mms;
|
|
|
|
import android.content.Context;
|
|
import android.os.Bundle;
|
|
|
|
import com.android.mms.service_alt.MmsConfig;
|
|
|
|
class MmsMediaConstraints extends MediaConstraints {
|
|
|
|
private static final int DEFAULT_MAX_IMAGE_DIMEN = 1024;
|
|
private static final int DEFAULT_MAX_MESSAGE_SIZE = 280 * 1024;
|
|
|
|
private final int subscriptionId;
|
|
|
|
MmsMediaConstraints(int subscriptionId) {
|
|
this.subscriptionId = subscriptionId;
|
|
}
|
|
|
|
@Override
|
|
public int getImageMaxWidth(Context context) {
|
|
MmsConfig mmsConfig = MmsConfigManager.getMmsConfig(context, subscriptionId);
|
|
|
|
if (mmsConfig != null) {
|
|
MmsConfig.Overridden overridden = new MmsConfig.Overridden(mmsConfig, new Bundle());
|
|
return overridden.getMaxImageWidth();
|
|
}
|
|
|
|
return DEFAULT_MAX_IMAGE_DIMEN;
|
|
}
|
|
|
|
@Override
|
|
public int getImageMaxHeight(Context context) {
|
|
MmsConfig mmsConfig = MmsConfigManager.getMmsConfig(context, subscriptionId);
|
|
|
|
if (mmsConfig != null) {
|
|
MmsConfig.Overridden overridden = new MmsConfig.Overridden(mmsConfig, new Bundle());
|
|
return overridden.getMaxImageHeight();
|
|
}
|
|
|
|
return DEFAULT_MAX_IMAGE_DIMEN;
|
|
}
|
|
|
|
@Override
|
|
public int getImageMaxSize(Context context) {
|
|
return getMaxMessageSize(context);
|
|
}
|
|
|
|
@Override
|
|
public int getGifMaxSize(Context context) {
|
|
return getMaxMessageSize(context);
|
|
}
|
|
|
|
@Override
|
|
public int getVideoMaxSize(Context context) {
|
|
return getMaxMessageSize(context);
|
|
}
|
|
|
|
@Override
|
|
public int getAudioMaxSize(Context context) {
|
|
return getMaxMessageSize(context);
|
|
}
|
|
|
|
@Override
|
|
public int getDocumentMaxSize(Context context) {
|
|
return getMaxMessageSize(context);
|
|
}
|
|
|
|
private int getMaxMessageSize(Context context) {
|
|
MmsConfig mmsConfig = MmsConfigManager.getMmsConfig(context, subscriptionId);
|
|
|
|
if (mmsConfig != null) {
|
|
MmsConfig.Overridden overridden = new MmsConfig.Overridden(mmsConfig, new Bundle());
|
|
return overridden.getMaxMessageSize();
|
|
}
|
|
|
|
return DEFAULT_MAX_MESSAGE_SIZE;
|
|
}
|
|
}
|