use of com.google.android.mms.MmsException in project android-aosp-mms by slvn.
the class ReadRecTransaction method run.
public void run() {
PduPersister persister = PduPersister.getPduPersister(mContext);
try {
// Load M-read-rec.ind from outbox
ReadRecInd readRecInd = (ReadRecInd) persister.load(mReadReportURI);
// insert the 'from' address per spec
String lineNumber = MessageUtils.getLocalNumber();
readRecInd.setFrom(new EncodedStringValue(lineNumber));
// Pack M-read-rec.ind and send it
byte[] postingData = new PduComposer(mContext, readRecInd).make();
sendPdu(postingData);
Uri uri = persister.move(mReadReportURI, Sent.CONTENT_URI);
mTransactionState.setState(TransactionState.SUCCESS);
mTransactionState.setContentUri(uri);
} catch (IOException e) {
if (LOCAL_LOGV) {
Log.v(TAG, "Failed to send M-Read-Rec.Ind.", e);
}
} catch (MmsException e) {
if (LOCAL_LOGV) {
Log.v(TAG, "Failed to load message from Outbox.", e);
}
} catch (RuntimeException e) {
if (LOCAL_LOGV) {
Log.e(TAG, "Unexpected RuntimeException.", e);
}
} finally {
if (mTransactionState.getState() != TransactionState.SUCCESS) {
mTransactionState.setState(TransactionState.FAILED);
mTransactionState.setContentUri(mReadReportURI);
}
notifyObservers();
}
}
use of com.google.android.mms.MmsException in project android-aosp-mms by slvn.
the class SlideEditorActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.edit_slide_activity);
mSlideView = (BasicSlideEditorView) findViewById(R.id.slide_editor_view);
mSlideView.setOnTextChangedListener(mOnTextChangedListener);
mPreSlide = (ImageButton) findViewById(R.id.pre_slide_button);
mPreSlide.setOnClickListener(mOnNavigateBackward);
mNextSlide = (ImageButton) findViewById(R.id.next_slide_button);
mNextSlide.setOnClickListener(mOnNavigateForward);
mPreview = (Button) findViewById(R.id.preview_button);
mPreview.setOnClickListener(mOnPreview);
mReplaceImage = (Button) findViewById(R.id.replace_image_button);
mReplaceImage.setOnClickListener(mOnReplaceImage);
mRemoveSlide = (Button) findViewById(R.id.remove_slide_button);
mRemoveSlide.setOnClickListener(mOnRemoveSlide);
mTextEditor = (EditText) findViewById(R.id.text_message);
mTextEditor.setFilters(new InputFilter[] { new LengthFilter(MmsConfig.getMaxTextLimit()) });
mDone = (Button) findViewById(R.id.done_button);
mDone.setOnClickListener(mDoneClickListener);
initActivityState(savedInstanceState, getIntent());
try {
mSlideshowModel = SlideshowModel.createFromMessageUri(this, mUri);
// Confirm that we have at least 1 slide to display
if (mSlideshowModel.size() == 0) {
Log.e(TAG, "Loaded slideshow is empty; can't edit nothingness, exiting.");
finish();
return;
}
// Register an observer to watch whether the data model is changed.
mSlideshowModel.registerModelChangedObserver(mModelChangedObserver);
mSlideshowEditor = new SlideshowEditor(this, mSlideshowModel);
mPresenter = (SlideshowPresenter) PresenterFactory.getPresenter("SlideshowPresenter", this, mSlideView, mSlideshowModel);
// Sanitize mPosition
if (mPosition >= mSlideshowModel.size()) {
mPosition = Math.max(0, mSlideshowModel.size() - 1);
} else if (mPosition < 0) {
mPosition = 0;
}
showCurrentSlide();
} catch (MmsException e) {
Log.e(TAG, "Create SlideshowModel failed!", e);
finish();
return;
}
}
use of com.google.android.mms.MmsException in project android-aosp-mms by slvn.
the class SlideshowActivity method onCreate.
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
mHandler = new Handler();
// Play slide-show in full-screen mode.
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFormat(PixelFormat.TRANSLUCENT);
setContentView(R.layout.slideshow);
Intent intent = getIntent();
Uri msg = intent.getData();
final SlideshowModel model;
try {
model = SlideshowModel.createFromMessageUri(this, msg);
mSlideCount = model.size();
} catch (MmsException e) {
Log.e(TAG, "Cannot present the slide show.", e);
finish();
return;
}
mSlideView = (SlideView) findViewById(R.id.slide_view);
PresenterFactory.getPresenter("SlideshowPresenter", this, mSlideView, model);
mHandler.post(new Runnable() {
private boolean isRotating() {
return mSmilPlayer.isPausedState() || mSmilPlayer.isPlayingState() || mSmilPlayer.isPlayedState();
}
public void run() {
mSmilPlayer = SmilPlayer.getPlayer();
if (mSlideCount > 1) {
// Only show the slideshow controller if we have more than a single slide.
// Otherwise, when we play a sound on a single slide, it appears like
// the slide controller should control the sound (seeking, ff'ing, etc).
initMediaController();
mSlideView.setMediaController(mMediaController);
}
// Use SmilHelper.getDocument() to ensure rebuilding the
// entire SMIL document.
mSmilDoc = SmilHelper.getDocument(model);
if (isMMSConformance(mSmilDoc)) {
int imageLeft = 0;
int imageTop = 0;
int textLeft = 0;
int textTop = 0;
LayoutModel layout = model.getLayout();
if (layout != null) {
RegionModel imageRegion = layout.getImageRegion();
if (imageRegion != null) {
imageLeft = imageRegion.getLeft();
imageTop = imageRegion.getTop();
}
RegionModel textRegion = layout.getTextRegion();
if (textRegion != null) {
textLeft = textRegion.getLeft();
textTop = textRegion.getTop();
}
}
mSlideView.enableMMSConformanceMode(textLeft, textTop, imageLeft, imageTop);
}
if (DEBUG) {
ByteArrayOutputStream ostream = new ByteArrayOutputStream();
SmilXmlSerializer.serialize(mSmilDoc, ostream);
if (LOCAL_LOGV) {
Log.v(TAG, ostream.toString());
}
}
// Add event listener.
((EventTarget) mSmilDoc).addEventListener(SmilDocumentImpl.SMIL_DOCUMENT_END_EVENT, SlideshowActivity.this, false);
mSmilPlayer.init(mSmilDoc);
if (isRotating()) {
mSmilPlayer.reload();
} else {
mSmilPlayer.play();
}
}
});
}
use of com.google.android.mms.MmsException in project android-aosp-mms by slvn.
the class DownloadManager method markState.
public void markState(final Uri uri, int state) {
// Notify user if the message has expired.
try {
NotificationInd nInd = (NotificationInd) PduPersister.getPduPersister(mContext).load(uri);
if ((nInd.getExpiry() < System.currentTimeMillis() / 1000L) && (state == STATE_DOWNLOADING || state == STATE_PRE_DOWNLOADING)) {
mHandler.post(new Runnable() {
public void run() {
Toast.makeText(mContext, R.string.service_message_not_found, Toast.LENGTH_LONG).show();
}
});
SqliteWrapper.delete(mContext, mContext.getContentResolver(), uri, null, null);
return;
}
} catch (MmsException e) {
Log.e(TAG, e.getMessage(), e);
return;
}
// Notify user if downloading permanently failed.
if (state == STATE_PERMANENT_FAILURE) {
mHandler.post(new Runnable() {
public void run() {
try {
Toast.makeText(mContext, getMessage(uri), Toast.LENGTH_LONG).show();
} catch (MmsException e) {
Log.e(TAG, e.getMessage(), e);
}
}
});
} else if (!mAutoDownload) {
state |= DEFERRED_MASK;
}
// Use the STATUS field to store the state of downloading process
// because it's useless for M-Notification.ind.
ContentValues values = new ContentValues(1);
values.put(Mms.STATUS, state);
SqliteWrapper.update(mContext, mContext.getContentResolver(), uri, values, null, null);
}
use of com.google.android.mms.MmsException in project android-aosp-mms by slvn.
the class WorkingMessage method updateDraftMmsMessage.
private static void updateDraftMmsMessage(Uri uri, PduPersister persister, SlideshowModel slideshow, SendReq sendReq, HashMap<Uri, InputStream> preOpenedFiles) {
if (Log.isLoggable(LogTag.APP, Log.VERBOSE)) {
LogTag.debug("updateDraftMmsMessage uri=%s", uri);
}
if (uri == null) {
Log.e(TAG, "updateDraftMmsMessage null uri");
return;
}
persister.updateHeaders(uri, sendReq);
final PduBody pb = slideshow.toPduBody();
try {
persister.updateParts(uri, pb, preOpenedFiles);
} catch (MmsException e) {
Log.e(TAG, "updateDraftMmsMessage: cannot update message " + uri);
}
slideshow.sync(pb);
}
Aggregations