MAP: Add proper version during map email use cases

Fix:
Use message version, message listing version and
event filter variables of parent class to avoid
format related issue and send removed event
when message has been irrevocably removed from
the reported folder.

CRs-Fixed: 2419971
Change-Id: Ibe528589e43e0c16d36a032335ff2f7b97adaff8
diff --git a/packages_apps_bluetooth_ext/src/map/src/BluetoothMapContentEmail.java b/packages_apps_bluetooth_ext/src/map/src/BluetoothMapContentEmail.java
index 40da4eb..655fbf1 100644
--- a/packages_apps_bluetooth_ext/src/map/src/BluetoothMapContentEmail.java
+++ b/packages_apps_bluetooth_ext/src/map/src/BluetoothMapContentEmail.java
@@ -120,11 +120,9 @@
     private final BluetoothMapAccountItem mAccount;
     /* The MasInstance reference is used to update persistent (over a connection) version counters*/
     private final BluetoothMapMasInstance mMasInstance;
-    private String mMessageVersion = BluetoothMapUtils.MAP_V10_STR;
     private final boolean EMAIL_ATTACHMENT_IMPLEMENTED = false;
 
     private int mRemoteFeatureMask = BluetoothMapUtils.MAP_FEATURE_DEFAULT_BITMASK;
-    private int mMsgListingVersion = BluetoothMapUtils.MAP_MESSAGE_LISTING_FORMAT_V10;
 
     private class FilterInfo {
             public static final int TYPE_SMS    = 0;
diff --git a/packages_apps_bluetooth_ext/src/map/src/BluetoothMapContentObserverEmail.java b/packages_apps_bluetooth_ext/src/map/src/BluetoothMapContentObserverEmail.java
index 005dc42..a99f7a0 100644
--- a/packages_apps_bluetooth_ext/src/map/src/BluetoothMapContentObserverEmail.java
+++ b/packages_apps_bluetooth_ext/src/map/src/BluetoothMapContentObserverEmail.java
@@ -111,7 +111,7 @@
     private static final long EVENT_FILTER_CONVERSATION_CHANGED         = 1L<<10;
     private static final long EVENT_FILTER_PARTICIPANT_PRESENCE_CHANGED = 1L<<11;
     private static final long EVENT_FILTER_PARTICIPANT_CHATSTATE_CHANGED= 1L<<12;
-    private static final long EVENT_FILTER_MESSAGE_REMOVED              = 1L<<13;
+    private static final long EVENT_FILTER_MESSAGE_REMOVED              = 1L<<14;
 
     // TODO: If we are requesting a large message from the network, on a slow connection
     //       20 seconds might not be enough... But then again 20 seconds is long for other
@@ -141,14 +141,6 @@
 
     private boolean mTransmitEvents = true;
 
-    /* To make the filter update atomic, we declare it volatile.
-     * To avoid a penalty when using it, copy the value to a local
-     * non-volatile variable when used more than once.
-     * Actually we only ever use the lower 4 bytes of this variable,
-     * hence we could manage without the volatile keyword, but as
-     * we tend to copy ways of doing things, we better do it right:-) */
-    private volatile long mEventFilter = 0xFFFFFFFFL;
-
     public static final int DELETED_THREAD_ID = -1;
 
     // X-Mms-Message-Type field types. These are from PduHeaders.java
@@ -254,8 +246,8 @@
     }
 
     public int getObserverRemoteFeatureMask() {
-        if (V) Log.v(TAG, "getObserverRemoteFeatureMask Email: " + mMapEventReportVersion
-            + " mMapSupportedFeatures Email: " + mMapSupportedFeatures);
+        if (V) Log.v(TAG, "getObserverRemoteFeatureMask " + mMapEventReportVersion
+            + " mMapSupportedFeatures :" + mMapSupportedFeatures);
         return mMapSupportedFeatures;
     }
 
@@ -398,7 +390,7 @@
 
         /* Enable use of the cache for checking the filter */
         long eventFilter = mEventFilter;
-
+        if (V) Log.v(TAG," eventFilter " + eventFilter);
         /* This should have been a switch on the string, but it is not allowed in Java 1.6 */
         /* WARNING: Here we do pointer compare for the string to speed up things, that is.
          * HENCE: always use the EVENT_TYPE_"defines" */
@@ -550,7 +542,7 @@
                             msgList.put(id, msg);
                             Event evt;
                             /* Incoming message from the network */
-                            if (mMapEventReportVersion == BluetoothMapUtils.MAP_EVENT_REPORT_V11) {
+                            if (mMapEventReportVersion >= BluetoothMapUtils.MAP_EVENT_REPORT_V11) {
                                 String date = BluetoothMapUtils.getDateTimeString(c.getLong(c
                                     .getColumnIndex(BluetoothMapEmailContract
                                     .ExtEmailMessageColumns.TIMESTAMP)));
@@ -691,7 +683,12 @@
                 if (!msg.transparent ) {
                     if(msg.localInitiatedShift == false ) {
                         // "old_folder" used only for MessageShift event
-                        Event evt = new Event(EVENT_TYPE_DELETE, msg.id, oldFolder,
+                        String eventType = EVENT_TYPE_DELETE;
+                        if (mMapEventReportVersion >= BluetoothMapUtils.MAP_EVENT_REPORT_V12) {
+                            eventType = EVENT_TYPE_REMOVED;
+                            if (V) Log.v(TAG," send EVENT_TYPE_REMOVED");
+                        }
+                        Event evt = new Event(eventType, msg.id, oldFolder,
                             null, mAccount.getType());
                         sendEvent(evt);
                     } else {