event_manager: Fix a mismatch of params in update reportFullyDrawn.

Test: Make
Test: Run an app that has reportFullyDrawn in the phone and examine the
sqlite db.

Change-Id: If735e4bdd86a812fdc5d0845eff63f9958567d22
diff --git a/src/db/models.h b/src/db/models.h
index aa09d38..94f82da 100644
--- a/src/db/models.h
+++ b/src/db/models.h
@@ -828,17 +828,17 @@
 
   static bool UpdateReportFullyDrawn(DbHandle db,
                                      int history_id,
-                                     std::optional<uint64_t> report_fully_drawn_ns)
+                                     uint64_t report_fully_drawn_ns)
   {
     const char* sql = "UPDATE app_launch_histories "
                       "SET report_fully_drawn_ns = ?1 "
                       "WHERE id = ?2;";
 
-    bool result = DbQueryBuilder::Update(db, sql, history_id, report_fully_drawn_ns);
+    bool result = DbQueryBuilder::Update(db, sql, report_fully_drawn_ns, history_id);
 
     if (!result) {
       LOG(ERROR)<< "Failed to update history_id:"<< history_id
-                << ", report_fully_drawn_ns: " << report_fully_drawn_ns.value();
+                << ", report_fully_drawn_ns: " << report_fully_drawn_ns;
     }
     return result;
   }
diff --git a/src/manager/event_manager.cc b/src/manager/event_manager.cc
index 77a1b18..f6655a6 100644
--- a/src/manager/event_manager.cc
+++ b/src/manager/event_manager.cc
@@ -256,7 +256,8 @@
           LOG(WARNING) << "Dangling kReportFullyDrawn event";
           return;
         }
-        UpdateReportFullyDrawn(event.timestamp_nanos, *recent_history_id_);
+        UpdateReportFullyDrawn(*recent_history_id_, event.timestamp_nanos);
+        recent_history_id_ = std::nullopt;
         break;
       }
       default:
@@ -508,6 +509,11 @@
   }
 
   void UpdateReportFullyDrawn(int history_id, uint64_t timestamp_ns) {
+    LOG(DEBUG) << "Update kReportFullyDrawn for history_id:"
+               << history_id
+               << " timestamp_ns: "
+               << timestamp_ns;
+
     android::ScopedTrace trace{ATRACE_TAG_PACKAGE_MANAGER,
                                "IorapNativeService::UpdateReportFullyDrawn"};
     db::DbHandle db{db::SchemaModel::GetSingleton()};