Camera: Release online and offline resources

Clear the cached previous request in case of
successful offline switch. The request can
potentially continue to have valid references
to offline streams.
Clear the online camera device reference after
composite streams switch to offline mode.
In this case, all internal offline streams must
be released by the offline session.

Bug: 149346795
Test: Camera CTS
Change-Id: If29308dd0f402ab492e304e0475005b2a9801e74
diff --git a/services/camera/libcameraservice/api2/CompositeStream.cpp b/services/camera/libcameraservice/api2/CompositeStream.cpp
index 354eaf9..b47ee2e 100644
--- a/services/camera/libcameraservice/api2/CompositeStream.cpp
+++ b/services/camera/libcameraservice/api2/CompositeStream.cpp
@@ -200,5 +200,10 @@
     }
 }
 
+void CompositeStream::switchToOffline() {
+    Mutex::Autolock l(mMutex);
+    mDevice.clear();
+}
+
 }; // namespace camera3
 }; // namespace android