Merge cherrypicks of [5532243, 5532244, 5532245, 5532246, 5532247, 5532826, 5530552, 5532902, 5530553, 5531520, 5532903, 5530554, 5529581, 5529582, 5531521, 5532979, 5532999, 5532248, 5531522, 5531523, 5531524, 5531525, 5531526, 5529583, 5529584, 5529585, 5529586, 5531351, 5529632, 5530506, 5530507, 5532980, 5533000] into pi-qpr1-release

Change-Id: Ia8826498572929e11720e65224b9e48f32caf9d1
diff --git a/sdm845/core/SystemStatusOsObserver.cpp b/sdm845/core/SystemStatusOsObserver.cpp
index 0f6d228..8127e86 100644
--- a/sdm845/core/SystemStatusOsObserver.cpp
+++ b/sdm845/core/SystemStatusOsObserver.cpp
@@ -328,9 +328,12 @@
             for (auto client : clientSet) {
                 unordered_set<DataItemId> dataItemIdsForThisClient(
                         mParent->mClientToDataItems.getValSet(client));
-                for (auto id : dataItemIdsForThisClient) {
-                    if (dataItemIdsToBeSent.find(id) == dataItemIdsToBeSent.end()) {
-                        dataItemIdsForThisClient.erase(id);
+                for (auto itr = dataItemIdsForThisClient.begin();
+                        itr != dataItemIdsForThisClient.end(); ) {
+                    if (dataItemIdsToBeSent.find(*itr) == dataItemIdsToBeSent.end()) {
+                        itr = dataItemIdsForThisClient.erase(itr);
+                    } else {
+                        itr++;
                     }
                 }