MAP: Fix Format issue with v1.3 device.

Pre-condition:
Use MCE V1.3 as peer device

Use case
1) Unbound all from DUT
2) After MAP Connect, set path to inbox do message listing

Observed Result:
DUT broadcasting MSE V1.2 during SDP but sending
response in V1.4 format.

Fix:
Added extra check which remote MCE version and repair status
while calculating remote feature bits. So that DUT send
response in correct format based on broadcasted sdp record.

CRs-Fixed: 2616011
Change-Id: I3bf1ee323f5cc63aa4c77b0ba8b8d956be5826ef
diff --git a/src/com/android/bluetooth/map/BluetoothMapMasInstance.java b/src/com/android/bluetooth/map/BluetoothMapMasInstance.java
index e4270b1..8e0b2d3 100644
--- a/src/com/android/bluetooth/map/BluetoothMapMasInstance.java
+++ b/src/com/android/bluetooth/map/BluetoothMapMasInstance.java
@@ -477,16 +477,17 @@
         }
     }
 
-    public void setRemoteFeatureMask(int supportedFeatures, int remoteProfileVersion) {
-        Log.d(mTag, "setRemoteFeatureMask supportedFeatures : "
+    public void setRemoteFeatureMask(int supportedFeatures, int remoteProfileVersion,
+            BluetoothDevice rd) {
+        if (D) Log.d(mTag, "setRemoteFeatureMask supportedFeatures "
                 + Integer.toHexString(supportedFeatures) +", remoteProfileVersion: "
                 + Integer.toHexString(remoteProfileVersion));
         mPeerProfileVersion = remoteProfileVersion;
         if (Utils.isPtsTestMode()) {
             mRemoteFeatureMask =
                     SDP_MAP_MAS_FEATURES_ADV;
-        } else if ((remoteProfileVersion > SDP_MAP_MAS_VERSION)
-            && (!BluetoothMapFixes.isMapAdvDisabled())){
+        } else if ((remoteProfileVersion > SDP_MAP_MAS_VERSION_ADV)
+            && (!BluetoothMapFixes.isMapAdvDisabled()  && BluetoothMapFixes.isRebonded(rd))){
             mRemoteFeatureMask =
                 supportedFeatures & SDP_MAP_MAS_FEATURES_ADV;
         } else {
diff --git a/src/com/android/bluetooth/map/BluetoothMapService.java b/src/com/android/bluetooth/map/BluetoothMapService.java
index 076916f..5c81376 100644
--- a/src/com/android/bluetooth/map/BluetoothMapService.java
+++ b/src/com/android/bluetooth/map/BluetoothMapService.java
@@ -1100,12 +1100,12 @@
                         mBluetoothMnsObexClient.setMnsRecord(mMnsRecord);
                     }
                     if (status != -1 && mMnsRecord != null) {
+                        BluetoothMapFixes.showNotification(BluetoothMapService.this, remoteDevice);
                         for (int i = 0, c = mMasInstances.size(); i < c; i++) {
                             mMasInstances.valueAt(i)
                                     .setRemoteFeatureMask(mMnsRecord.getSupportedFeatures(),
-                                    mMnsRecord.getProfileVersion());
+                                    mMnsRecord.getProfileVersion(), remoteDevice);
                         }
-                        BluetoothMapFixes.showNotification(BluetoothMapService.this, remoteDevice);
                     }
                     if (mSdpSearchInitiated) {
                         mSdpSearchInitiated = false; // done searching