Search in sources :

Example 81 with MmsException

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();
    }
}
Also used : EncodedStringValue(com.google.android.mms.pdu.EncodedStringValue) MmsException(com.google.android.mms.MmsException) PduPersister(com.google.android.mms.pdu.PduPersister) ReadRecInd(com.google.android.mms.pdu.ReadRecInd) IOException(java.io.IOException) Uri(android.net.Uri) PduComposer(com.google.android.mms.pdu.PduComposer)

Example 82 with MmsException

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;
    }
}
Also used : MmsException(com.google.android.mms.MmsException) LengthFilter(android.text.InputFilter.LengthFilter)

Example 83 with MmsException

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();
            }
        }
    });
}
Also used : MmsException(com.google.android.mms.MmsException) SlideshowModel(com.android.mms.model.SlideshowModel) Handler(android.os.Handler) Intent(android.content.Intent) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Uri(android.net.Uri) RegionModel(com.android.mms.model.RegionModel) LayoutModel(com.android.mms.model.LayoutModel)

Example 84 with MmsException

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);
}
Also used : ContentValues(android.content.ContentValues) MmsException(com.google.android.mms.MmsException) NotificationInd(com.google.android.mms.pdu.NotificationInd)

Example 85 with MmsException

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);
}
Also used : MmsException(com.google.android.mms.MmsException) PduBody(com.google.android.mms.pdu.PduBody)

Aggregations

MmsException (com.google.android.mms.MmsException)88 Uri (android.net.Uri)32 ContentValues (android.content.ContentValues)27 Cursor (android.database.Cursor)21 IOException (java.io.IOException)18 Intent (android.content.Intent)12 EncodedStringValue (com.google.android.mms.pdu.EncodedStringValue)9 PduBody (com.google.android.mms.pdu.PduBody)9 ByteArrayOutputStream (java.io.ByteArrayOutputStream)9 ContentResolver (android.content.ContentResolver)8 InputStream (java.io.InputStream)8 PduPersister (com.google.android.mms.pdu.PduPersister)7 PduPersister (com.google.android.mms.pdu_alt.PduPersister)7 Entry (java.util.Map.Entry)7 SpannableString (android.text.SpannableString)6 PduBody (com.google.android.mms.pdu_alt.PduBody)6 PduPart (com.google.android.mms.pdu_alt.PduPart)6 FileNotFoundException (java.io.FileNotFoundException)6 InvalidHeaderValueException (com.google.android.mms.InvalidHeaderValueException)5 PduPart (com.google.android.mms.pdu.PduPart)5