use of com.google.android.mms.pdu.EncodedStringValue 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.pdu.EncodedStringValue in project android-aosp-mms by slvn.
the class RetrieveTransaction method sendAcknowledgeInd.
private void sendAcknowledgeInd(RetrieveConf rc) throws MmsException, IOException {
// Send M-Acknowledge.ind to MMSC if required.
// If the Transaction-ID isn't set in the M-Retrieve.conf, it means
// the MMS proxy-relay doesn't require an ACK.
byte[] tranId = rc.getTransactionId();
if (tranId != null) {
// Create M-Acknowledge.ind
AcknowledgeInd acknowledgeInd = new AcknowledgeInd(PduHeaders.CURRENT_MMS_VERSION, tranId);
// insert the 'from' address per spec
String lineNumber = MessageUtils.getLocalNumber();
acknowledgeInd.setFrom(new EncodedStringValue(lineNumber));
// Pack M-Acknowledge.ind and send it
if (MmsConfig.getNotifyWapMMSC()) {
sendPdu(new PduComposer(mContext, acknowledgeInd).make(), mContentLocation);
} else {
sendPdu(new PduComposer(mContext, acknowledgeInd).make());
}
}
}
use of com.google.android.mms.pdu.EncodedStringValue in project android-aosp-mms by slvn.
the class AddressUtils method getFrom.
public static String getFrom(Context context, Uri uri) {
String msgId = uri.getLastPathSegment();
Uri.Builder builder = Mms.CONTENT_URI.buildUpon();
builder.appendPath(msgId).appendPath("addr");
Cursor cursor = SqliteWrapper.query(context, context.getContentResolver(), builder.build(), new String[] { Addr.ADDRESS, Addr.CHARSET }, Addr.TYPE + "=" + PduHeaders.FROM, null, null);
if (cursor != null) {
try {
if (cursor.moveToFirst()) {
String from = cursor.getString(0);
if (!TextUtils.isEmpty(from)) {
byte[] bytes = PduPersister.getBytes(from);
int charset = cursor.getInt(1);
return new EncodedStringValue(charset, bytes).getString();
}
}
} finally {
cursor.close();
}
}
return context.getString(R.string.hidden_sender_address);
}
use of com.google.android.mms.pdu.EncodedStringValue in project android-aosp-mms by slvn.
the class DownloadManager method getMessage.
private String getMessage(Uri uri) throws MmsException {
NotificationInd ind = (NotificationInd) PduPersister.getPduPersister(mContext).load(uri);
EncodedStringValue v = ind.getSubject();
String subject = (v != null) ? v.getString() : mContext.getString(R.string.no_subject);
v = ind.getFrom();
String from = (v != null) ? Contact.get(v.getString(), false).getName() : mContext.getString(R.string.unknown_sender);
return mContext.getString(R.string.dl_failure_notification, subject, from);
}
Aggregations