Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c5409061 authored by Ashwini Munigala's avatar Ashwini Munigala Committed by Linux Build Service Account
Browse files

MAP: Fix KW Issues for MAP.

Modifications to fix KW P1 or
critical issues captured from KlocWork.

Change-Id: Ie7100907513147f0d743b579998a16880ebf734f
CRs-fixed: 739477
parent aac988ce
Loading
Loading
Loading
Loading
+49 −21
Original line number Diff line number Diff line
@@ -291,6 +291,7 @@ public class BluetoothMapContent {
                }

            } while(c.moveToNext());
            c.close();
        }
    }

@@ -355,6 +356,7 @@ public class BluetoothMapContent {
                /*     printMmsPartImage(partid); */
                /* } */
            } while(c.moveToNext());
            c.close();
        }
    }

@@ -460,6 +462,7 @@ public class BluetoothMapContent {
        dumpMmsTable();

        BluetoothMapAppParams ap = buildAppParams();
        if(ap != null ){
            if (D) Log.d(TAG, "message listing size = " + msgListingSize("inbox", ap));
            BluetoothMapMessageListing mList = msgListing("inbox", ap);
            try {
@@ -473,9 +476,16 @@ public class BluetoothMapContent {
            } catch (UnsupportedEncodingException ex) {
               /* do nothing */
            }
        } else {
            if (D) Log.d(TAG, "dumPMessage AppParams not available ");
        }
    }

    public static String decodeEncodedWord(String checkEncoded) {
        if (checkEncoded == null) {
            if(V) Log.v(TAG, " Decode Invalid Input");
            return null;
        }
        if (checkEncoded != null && (checkEncoded.contains("=?") == false)) {
            if(V) Log.v(TAG, " Decode NotRequired" + checkEncoded);
            return checkEncoded;
@@ -1047,7 +1057,8 @@ public class BluetoothMapContent {
        } else {
            type = TYPE.EMAIL;
        }
        if (D) Log.d(TAG, "setHandle: " + handle + " - Type: " + type.name());
        if (D && type != null)
           Log.d(TAG, "setHandle: " + handle + " - Type: " + type.name());
        e.setHandle(handle, type);
    }

@@ -1905,11 +1916,11 @@ public class BluetoothMapContent {
                          Log.v(TAG, " recepientStr[1] " + recepientStr[1].trim());
                          Log.v(TAG, " recepientStr[0] " + recepientStr[0].trim());
                      }
                } else if(recipientName.contains("")){
                      multiRecepients = recipientName.replace('', ';');
                      setVCardFromEmailAddress(message, recepientStr[1].trim(), false);
                      message.addCc(recepientStr[1].trim(), recepientStr[0].trim());
                   }
                } else if(recipientName.contains("")){
                      multiRecepients = recipientName.replace('', ';');
                      if(multiRecepients != null){
                         if (V){
                             Log.v(TAG, " Setting ::Recepient name :: " + multiRecepients.trim());
@@ -1950,6 +1961,7 @@ public class BluetoothMapContent {
                      }
              }
             }
            c.close();
        }
    }

@@ -1970,9 +1982,11 @@ public class BluetoothMapContent {
        try {
            is = mResolver.openInputStream(uriAddress);
            int len = 0;
            if ((is != null) && (os != null)) {
                while ((len = is.read(buffer)) != -1) {
                  os.write(buffer, 0, len); // We need to specify the len, as it can be != bufferSize
                }
            }
            retVal = os.toByteArray();
        } catch (IOException e) {
            // do nothing for now
@@ -1980,6 +1994,7 @@ public class BluetoothMapContent {
        } finally {
            try {
                os.close();
                if(is != null)
                   is.close();
            } catch (IOException e) {
            }
@@ -2065,7 +2080,12 @@ public class BluetoothMapContent {
                            } catch (NullPointerException e) {
                                if(V) Log.w(TAG, e);
                            }
                            String msgBody = readEmailBodyForMessageFd(fd);
                            String msgBody = null ;
                            if(fd != null ) {
                               msgBody = readEmailBodyForMessageFd(fd);
                            } else {
                               Log.w(TAG, " FETCH Email BODY File HTML URI FAILED");
                            }
                            if (msgBody != null) {
                                msgBody = msgBody.replaceAll("(?s)(<title>)(.*?)(</title>)", "");
                                msgBody = msgBody.replaceAll("(?s)(<style type=\"text/css\".*?>)(.*?)(</style>)", "");
@@ -2469,6 +2489,9 @@ public class BluetoothMapContent {
    public byte[] getMessage(String handle, BluetoothMapAppParams appParams) throws UnsupportedEncodingException{
        TYPE type = BluetoothMapUtils.getMsgTypeFromHandle(handle);
        long id = BluetoothMapUtils.getCpHandle(handle);
        if(appParams == null){
                throw new IllegalArgumentException("Invalid No appParams Charset");
        }
        switch(type) {
        case SMS_GSM:
        case SMS_CDMA:
@@ -2599,6 +2622,9 @@ public class BluetoothMapContent {
                message.setType(TYPE.SMS_GSM);
            } else if (tm.getPhoneType() == TelephonyManager.PHONE_TYPE_CDMA) {
                message.setType(TYPE.SMS_CDMA);
            } else {
                // set SMS_GSM by default
                message.setType(TYPE.SMS_GSM);
            }

            String read = c.getString(c.getColumnIndex(Sms.READ));
@@ -2672,6 +2698,7 @@ public class BluetoothMapContent {
                    break;
                }
            } while(c.moveToNext());
            c.close();
        }
    }

@@ -2791,6 +2818,7 @@ public class BluetoothMapContent {
                }
                part.fileName = filename;
            } while(c.moveToNext());
            c.close();
        }
        message.updateCharset();
    }
+3 −2
Original line number Diff line number Diff line
@@ -172,7 +172,8 @@ public class BluetoothMapContentEmailObserver extends BluetoothMapContentObserve

        @Override
        public void onChange(boolean selfChange, Uri uri) {
            if (V) Log.v(TAG, "onChange on thread: " + Thread.currentThread().getId()
            if (V && uri!= null)
                Log.v(TAG, "onChange on thread: " + Thread.currentThread().getId()
                    + " Uri: " + uri.toString() + " selfchange: " + selfChange);

             if (mHandler.hasMessages(UPDATE)) {
+8 −4
Original line number Diff line number Diff line
@@ -140,7 +140,8 @@ public class BluetoothMapContentObserver {

        @Override
        public void onChange(boolean selfChange, Uri uri) {
            if (V) Log.d(TAG, "onChange on thread: " + Thread.currentThread().getId()
            if (V && uri!= null)
                Log.d(TAG, "onChange on thread: " + Thread.currentThread().getId()
                   + " Uri: " + uri.toString() + " selfchange: " + selfChange);

            handleMsgListChanges();
@@ -676,6 +677,7 @@ public class BluetoothMapContentObserver {
    public boolean setMessageStatusRead(long handle, TYPE type, int statusValue) {
        boolean res = true;

        Cursor c = null;
        if (D) Log.d(TAG, "setMessageStatusRead: handle " + handle
            + " type " + type + " value " + statusValue);

@@ -684,20 +686,22 @@ public class BluetoothMapContentObserver {

        if (type == TYPE.SMS_GSM || type == TYPE.SMS_CDMA) {
            Uri uri = ContentUris.withAppendedId(Sms.CONTENT_URI, handle);
            Cursor c = mResolver.query(uri, null, null, null, null);
            c = mResolver.query(uri, null, null, null, null);

            ContentValues contentValues = new ContentValues();
            contentValues.put(Sms.READ, statusValue);
            mResolver.update(uri, contentValues, null, null);
        } else if (type == TYPE.MMS) {
            Uri uri = ContentUris.withAppendedId(Mms.CONTENT_URI, handle);
            Cursor c = mResolver.query(uri, null, null, null, null);
            c = mResolver.query(uri, null, null, null, null);

            ContentValues contentValues = new ContentValues();
            contentValues.put(Mms.READ, statusValue);
            mResolver.update(uri, contentValues, null, null);
        }

        if (c !=null)
            c.close();
        return res;
    }

+1 −1
Original line number Diff line number Diff line
@@ -124,7 +124,7 @@ public class BluetoothMapMessageListing {
                int line1 = 0;
                line1 = str1.indexOf("\n");
                str2 += str1.substring(line1 + 1);
                if (list.size() > 0) {
                if (list != null  && list.size() > 0) {
                    int indxHandle = str2.indexOf("msg handle");
                    str1 = "<" + str2.substring(indxHandle);
                    str2 = str2.substring(0, (indxHandle - 1)) + str1;
+15 −3
Original line number Diff line number Diff line
@@ -257,17 +257,17 @@ public class BluetoothMapObexServer extends ServerRequestHandler {
            return ResponseCodes.OBEX_HTTP_NOT_IMPLEMENTED;
            }
        }else if(type.equals(TYPE_SET_NOTIFICATION_REGISTRATION)) {
            if(V) {
            if(V && appParams != null) {
                Log.d(TAG,"TYPE_SET_NOTIFICATION_REGISTRATION: NotificationStatus: " + appParams.getNotificationStatus());
            }
            return setNotificationRegistration(appParams);
        }else if(type.equals(TYPE_SET_MESSAGE_STATUS)) {
            if(V) {
            if(V && appParams != null) {
                Log.d(TAG,"TYPE_SET_MESSAGE_STATUS: StatusIndicator: " + appParams.getStatusIndicator() + ", StatusValue: " + appParams.getStatusValue());
            }
            return setMessageStatus(name, appParams);
        } else if (type.equals(TYPE_MESSAGE)) {
            if(V) {
            if(V && appParams != null) {
                Log.d(TAG,"TYPE_MESSAGE: Transparet: " + appParams.getTransparent() +  ", Retry: " + appParams.getRetry());
                Log.d(TAG,"              charset: " + appParams.getCharset());
            }
@@ -279,6 +279,10 @@ public class BluetoothMapObexServer extends ServerRequestHandler {
    }

    private int setNotificationRegistration(BluetoothMapAppParams appParams) {
        if(appParams == null ){
            if(D) Log.d(TAG, "Missing mandatory appParams charset - ");
            return ResponseCodes.OBEX_HTTP_PRECON_FAILED;
        }
        // Forward the request to the MNS thread as a message - including the MAS instance ID.
        Handler mns = mMnsClient.getMessageHandler();
        if(mns != null) {
@@ -295,6 +299,10 @@ public class BluetoothMapObexServer extends ServerRequestHandler {
    }

    private int pushMessage(final Operation op, String folderName, BluetoothMapAppParams appParams) {
        if(appParams == null ){
            if(D) Log.d(TAG, "Missing mandatory appParams charset - ");
            return ResponseCodes.OBEX_HTTP_PRECON_FAILED;
        }
        if(appParams.getCharset() == BluetoothMapAppParams.INVALID_VALUE_PARAMETER) {
            if(D) Log.d(TAG, "Missing charset - unable to decode message content. appParams.getCharset() = " + appParams.getCharset());
            return ResponseCodes.OBEX_HTTP_PRECON_FAILED;
@@ -346,6 +354,10 @@ public class BluetoothMapObexServer extends ServerRequestHandler {
    }

    private int setMessageStatus(String msgHandle, BluetoothMapAppParams appParams) {
        if(appParams == null ){
            if(D) Log.d(TAG, "Missing mandatory appParams ");
            return ResponseCodes.OBEX_HTTP_PRECON_FAILED;
        }
        int indicator = appParams.getStatusIndicator();
        int value = appParams.getStatusValue();
        long handle;
Loading