2015-01-02 23:43:28 +00:00
|
|
|
package org.thoughtcrime.securesms.mms;
|
|
|
|
|
2015-06-04 21:19:10 +00:00
|
|
|
import android.content.Context;
|
2017-05-08 22:32:59 +00:00
|
|
|
import android.os.Bundle;
|
2015-06-04 21:19:10 +00:00
|
|
|
|
2017-05-08 22:32:59 +00:00
|
|
|
import com.android.mms.service_alt.MmsConfig;
|
2015-06-04 21:19:10 +00:00
|
|
|
|
2017-05-08 22:32:59 +00:00
|
|
|
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;
|
|
|
|
}
|
2015-01-02 23:43:28 +00:00
|
|
|
|
|
|
|
@Override
|
2015-06-04 21:19:10 +00:00
|
|
|
public int getImageMaxWidth(Context context) {
|
2017-05-08 22:32:59 +00:00
|
|
|
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;
|
2015-01-02 23:43:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-06-04 21:19:10 +00:00
|
|
|
public int getImageMaxHeight(Context context) {
|
2017-05-08 22:32:59 +00:00
|
|
|
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;
|
2015-01-02 23:43:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2017-05-08 22:32:59 +00:00
|
|
|
public int getImageMaxSize(Context context) {
|
|
|
|
return getMaxMessageSize(context);
|
2015-01-02 23:43:28 +00:00
|
|
|
}
|
|
|
|
|
2015-07-15 20:42:59 +00:00
|
|
|
@Override
|
2017-05-08 22:32:59 +00:00
|
|
|
public int getGifMaxSize(Context context) {
|
|
|
|
return getMaxMessageSize(context);
|
2015-07-15 20:42:59 +00:00
|
|
|
}
|
|
|
|
|
2015-01-02 23:43:28 +00:00
|
|
|
@Override
|
2017-05-08 22:32:59 +00:00
|
|
|
public int getVideoMaxSize(Context context) {
|
|
|
|
return getMaxMessageSize(context);
|
2015-01-02 23:43:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2017-05-08 22:32:59 +00:00
|
|
|
public int getAudioMaxSize(Context context) {
|
|
|
|
return getMaxMessageSize(context);
|
2015-01-02 23:43:28 +00:00
|
|
|
}
|
2017-04-24 22:52:48 +00:00
|
|
|
|
|
|
|
@Override
|
2017-05-08 22:32:59 +00:00
|
|
|
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;
|
2017-04-24 22:52:48 +00:00
|
|
|
}
|
2015-01-02 23:43:28 +00:00
|
|
|
}
|