MTP: Send an Intent after an MTP session that resulted in media database modifications

Change-Id: Ib2796e9155350c67769502935a73cf98d6ae9c08
Signed-off-by: Mike Lockwood <lockwood@android.com>
diff --git a/media/mtp/MtpDatabase.h b/media/mtp/MtpDatabase.h
index 899b34a..c8cb016 100644
--- a/media/mtp/MtpDatabase.h
+++ b/media/mtp/MtpDatabase.h
@@ -93,6 +93,10 @@
                                             MtpObjectFormat format) = 0;
 
     virtual MtpProperty*            getDevicePropertyDesc(MtpDeviceProperty property) = 0;
+
+    virtual void                    sessionStarted() = 0;
+
+    virtual void                    sessionEnded() = 0;
 };
 
 }; // namespace android
diff --git a/media/mtp/MtpServer.cpp b/media/mtp/MtpServer.cpp
index 1e64e4f..c982114 100644
--- a/media/mtp/MtpServer.cpp
+++ b/media/mtp/MtpServer.cpp
@@ -185,6 +185,9 @@
             LOGV("skipping response\n");
         }
     }
+
+    if (mSessionOpen)
+        mDatabase->sessionEnded();
 }
 
 void MtpServer::sendObjectAdded(MtpObjectHandle handle) {
@@ -346,6 +349,9 @@
     }
     mSessionID = mRequest.getParameter(1);
     mSessionOpen = true;
+
+    mDatabase->sessionStarted();
+
     return MTP_RESPONSE_OK;
 }
 
@@ -354,6 +360,7 @@
         return MTP_RESPONSE_SESSION_NOT_OPEN;
     mSessionID = 0;
     mSessionOpen = false;
+    mDatabase->sessionEnded();
     return MTP_RESPONSE_OK;
 }