@Override
 @RunsOnMainThread
 public void onGetOrCreateConversationFailed(final ActionMonitor monitor, final Object data) {
   Assert.isTrue(monitor == mMonitor);
   LogUtil.e(LogUtil.BUGLE_TAG, "onGetOrCreateConversationFailed");
   mMonitor = null;
 }
 /** @return The debugging information of the parser's current position */
 private String xmlParserDebugContext() {
   mLogStringBuilder.setLength(0);
   if (mInputParser != null) {
     try {
       final int eventType = mInputParser.getEventType();
       mLogStringBuilder.append(xmlParserEventString(eventType));
       if (eventType == XmlPullParser.START_TAG
           || eventType == XmlPullParser.END_TAG
           || eventType == XmlPullParser.TEXT) {
         mLogStringBuilder.append('<').append(mInputParser.getName());
         for (int i = 0; i < mInputParser.getAttributeCount(); i++) {
           mLogStringBuilder
               .append(' ')
               .append(mInputParser.getAttributeName(i))
               .append('=')
               .append(mInputParser.getAttributeValue(i));
         }
         mLogStringBuilder.append("/>");
       }
       return mLogStringBuilder.toString();
     } catch (XmlPullParserException e) {
       LogUtil.e(TAG, "xmlParserDebugContext: " + e, e);
     }
   }
   return "Unknown";
 }
Exemple #3
0
 public static RetrieveConf parseRetrieveConf(byte[] data, int subId) {
   if (data != null) {
     final GenericPdu pdu =
         new PduParser(data, MmsConfig.get(subId).getSupportMmsContentDisposition()).parse();
     if (pdu != null) {
       if (pdu instanceof RetrieveConf) {
         return (RetrieveConf) pdu;
       } else {
         LogUtil.e(TAG, "MmsSender: downloaded pdu not RetrieveConf: " + pdu.getClass().getName());
       }
     } else {
       LogUtil.e(TAG, "MmsSender: downloaded pdu could not be parsed (invalid)");
     }
   }
   LogUtil.e(TAG, "MmsSender: downloaded pdu is empty");
   return null;
 }
 private Boolean parseBoolean(String text, Boolean defaultValue, String logHint) {
   Boolean value = defaultValue;
   try {
     value = Boolean.parseBoolean(text);
   } catch (Exception e) {
     LogUtil.e(TAG, "Invalid value " + text + "for" + logHint + " @" + xmlParserDebugContext());
   }
   return value;
 }
 private Integer parseInt(String text, Integer defaultValue, String logHint) {
   Integer value = defaultValue;
   try {
     value = Integer.parseInt(text);
   } catch (Exception e) {
     LogUtil.e(TAG, "Invalid value " + text + "for" + logHint + " @" + xmlParserDebugContext());
   }
   return value;
 }
Exemple #6
0
 public static SendConf parseSendConf(byte[] response, int subId) {
   if (response != null) {
     final GenericPdu respPdu =
         new PduParser(response, MmsConfig.get(subId).getSupportMmsContentDisposition()).parse();
     if (respPdu != null) {
       if (respPdu instanceof SendConf) {
         return (SendConf) respPdu;
       } else {
         LogUtil.e(TAG, "MmsSender: send response not SendConf");
       }
     } else {
       // Invalid PDU
       LogUtil.e(TAG, "MmsSender: send invalid response");
     }
   }
   // Empty or invalid response
   return null;
 }
Exemple #7
0
 private static Uri writePduToTempFile(final Context context, final GenericPdu pdu, int subId)
     throws MmsFailureException {
   final Uri contentUri = MmsFileProvider.buildRawMmsUri();
   final File tempFile = MmsFileProvider.getFile(contentUri);
   FileOutputStream writer = null;
   try {
     // Ensure rawmms directory exists
     tempFile.getParentFile().mkdirs();
     writer = new FileOutputStream(tempFile);
     final byte[] pduBytes = new PduComposer(context, pdu).make();
     if (pduBytes == null) {
       throw new MmsFailureException(MmsUtils.MMS_REQUEST_NO_RETRY, "Failed to compose PDU");
     }
     if (pduBytes.length > MmsConfig.get(subId).getMaxMessageSize()) {
       throw new MmsFailureException(
           MmsUtils.MMS_REQUEST_NO_RETRY, MessageData.RAW_TELEPHONY_STATUS_MESSAGE_TOO_BIG);
     }
     writer.write(pduBytes);
   } catch (final IOException e) {
     if (tempFile != null) {
       tempFile.delete();
     }
     LogUtil.e(TAG, "Cannot create temporary file " + tempFile.getAbsolutePath(), e);
     throw new MmsFailureException(MmsUtils.MMS_REQUEST_AUTO_RETRY, "Cannot create raw mms file");
   } catch (final OutOfMemoryError e) {
     if (tempFile != null) {
       tempFile.delete();
     }
     LogUtil.e(TAG, "Out of memory in composing PDU", e);
     throw new MmsFailureException(
         MmsUtils.MMS_REQUEST_MANUAL_RETRY, MessageData.RAW_TELEPHONY_STATUS_MESSAGE_TOO_BIG);
   } finally {
     if (writer != null) {
       try {
         writer.close();
       } catch (final IOException e) {
         // no action we can take here
       }
     }
   }
   return contentUri;
 }
 public void process() {
   try {
     // Find the first element
     if (advanceToNextEvent(XmlPullParser.START_TAG) != XmlPullParser.START_TAG) {
       throw new XmlPullParserException(
           "ApnsXmlProcessor: expecting start tag @" + xmlParserDebugContext());
     }
     // A single ContentValues object for holding the parsing result of
     // an apn element
     final ContentValues values = new ContentValues();
     String tagName = mInputParser.getName();
     // Top level tag can be "apns" (apns.xml)
     // or "mms_config" (mms_config.xml)
     if (TAG_APNS.equals(tagName)) {
       // For "apns", there could be "apn" or both "apn" and "mms_config"
       for (; ; ) {
         if (advanceToNextEvent(XmlPullParser.START_TAG) != XmlPullParser.START_TAG) {
           break;
         }
         tagName = mInputParser.getName();
         if (TAG_APN.equals(tagName)) {
           processApn(values);
         } else if (TAG_MMS_CONFIG.equals(tagName)) {
           processMmsConfig();
         }
       }
     } else if (TAG_MMS_CONFIG.equals(tagName)) {
       // mms_config.xml resource
       processMmsConfig();
     }
   } catch (IOException e) {
     LogUtil.e(TAG, "ApnsXmlProcessor: I/O failure " + e, e);
   } catch (XmlPullParserException e) {
     LogUtil.e(TAG, "ApnsXmlProcessor: parsing failure " + e, e);
   }
 }
 /** {@inheritDoc} */
 @Override
 public void dump(final FileDescriptor fd, final PrintWriter writer, final String[] args) {
   // First dump out the default SMS app package name
   String defaultSmsApp = PhoneUtils.getDefault().getDefaultSmsApp();
   if (TextUtils.isEmpty(defaultSmsApp)) {
     if (OsUtil.isAtLeastKLP()) {
       defaultSmsApp = "None";
     } else {
       defaultSmsApp = "None (pre-Kitkat)";
     }
   }
   writer.println("Default SMS app: " + defaultSmsApp);
   // Now dump logs
   LogUtil.dump(writer);
 }