OSDN Git Service

Merge "Introduce CaptureSessionFactory interface." into ub-camera-haleakala
authorSenpo Hu <senpo@google.com>
Thu, 19 Feb 2015 01:09:28 +0000 (01:09 +0000)
committerAndroid (Google) Code Review <android-gerrit@google.com>
Thu, 19 Feb 2015 01:09:29 +0000 (01:09 +0000)
src/com/android/camera/app/CameraServicesImpl.java
src/com/android/camera/session/CaptureSessionFactory.java [new file with mode: 0644]
src/com/android/camera/session/CaptureSessionFactoryImpl.java [new file with mode: 0644]
src/com/android/camera/session/CaptureSessionManager.java
src/com/android/camera/session/CaptureSessionManagerImpl.java

index 6b6038a..a1a2e86 100644 (file)
@@ -22,6 +22,8 @@ import com.android.camera.MediaSaverImpl;
 import com.android.camera.Storage;
 import com.android.camera.async.MainThread;
 import com.android.camera.remote.RemoteShutterListener;
+import com.android.camera.session.CaptureSessionFactory;
+import com.android.camera.session.CaptureSessionFactoryImpl;
 import com.android.camera.session.CaptureSessionManager;
 import com.android.camera.session.CaptureSessionManagerImpl;
 import com.android.camera.session.PlaceholderManager;
@@ -65,8 +67,10 @@ public class CameraServicesImpl implements CameraServices {
 
         StackSaverFactory mStackSaverFactory = new StackSaverFactory(Storage.DIRECTORY,
               context.getContentResolver());
-        mSessionManager = new CaptureSessionManagerImpl(mMediaSaver, mPlaceHolderManager,
-                mSessionStorageManager, mStackSaverFactory, MainThread.create());
+        CaptureSessionFactory captureSessionFactory = new CaptureSessionFactoryImpl(
+                mMediaSaver, mPlaceHolderManager, mSessionStorageManager, mStackSaverFactory);
+        mSessionManager = new CaptureSessionManagerImpl(
+                captureSessionFactory, mSessionStorageManager, MainThread.create());
         mMemoryManager = MemoryManagerImpl.create(context, mMediaSaver);
         mRemoteShutterListener = RemoteShutterHelper.create(context);
         mSettingsManager = new SettingsManager(context);
diff --git a/src/com/android/camera/session/CaptureSessionFactory.java b/src/com/android/camera/session/CaptureSessionFactory.java
new file mode 100644 (file)
index 0000000..df309e7
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.camera.session;
+
+import android.location.Location;
+
+public interface CaptureSessionFactory {
+    /**
+     * Creates a new capture session.
+     *
+     * @param sessionManager the capture session manager.
+     * @param title the title of the new session.
+     * @param sessionStartMillis the start time of the new session (millis since epoch).
+     * @param location the location of the new session.
+     */
+    public CaptureSession createNewSession(CaptureSessionManager sessionManager, String title,
+            long sessionStartMillis, Location location);
+}
diff --git a/src/com/android/camera/session/CaptureSessionFactoryImpl.java b/src/com/android/camera/session/CaptureSessionFactoryImpl.java
new file mode 100644 (file)
index 0000000..e0d282c
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.camera.session;
+
+import com.android.camera.app.MediaSaver;
+
+import android.location.Location;
+
+public class CaptureSessionFactoryImpl implements CaptureSessionFactory {
+    /** Sub-directory for storing temporary session files. */
+    private static final String TEMP_SESSIONS = "TEMP_SESSIONS";
+
+    private final MediaSaver mMediaSaver;
+    private final PlaceholderManager mPlaceholderManager;
+    private final SessionStorageManager mSessionStorageManager;
+    private final StackSaverFactory mStackSaverFactory;
+
+    public CaptureSessionFactoryImpl(MediaSaver mediaSaver, PlaceholderManager placeholderManager,
+            SessionStorageManager sessionStorageManager, StackSaverFactory stackSaverFactory) {
+        mMediaSaver = mediaSaver;
+        mPlaceholderManager = placeholderManager;
+        mSessionStorageManager = sessionStorageManager;
+        mStackSaverFactory = stackSaverFactory;
+    }
+
+    @Override
+    public CaptureSession createNewSession(CaptureSessionManager sessionManager, String title,
+            long sessionStartTime, Location location) {
+        TemporarySessionFile temporarySessionFile = new TemporarySessionFile(
+                mSessionStorageManager, TEMP_SESSIONS, title);
+        return new CaptureSessionImpl(title, sessionStartTime, location, temporarySessionFile,
+                (CaptureSessionManagerImpl) sessionManager, mPlaceholderManager, mMediaSaver,
+                mStackSaverFactory.create(title, location));
+    }
+}
index 6aa6fd5..7c9bc78 100644 (file)
@@ -72,7 +72,7 @@ public interface CaptureSessionManager {
      * @param sessionStartMillis the start time of the new session (millis since epoch).
      * @param location the location of the new session.
      */
-    CaptureSession createNewSession(String title, long sessionStartMillis, Location location);
+    public CaptureSession createNewSession(String title, long sessionStartMillis, Location location);
 
     /**
      * Returns a session by session Uri or null if it is not found.
@@ -81,7 +81,7 @@ public interface CaptureSessionManager {
      *
      * @return The corresponding CaptureSession.
      */
-    CaptureSession getSession(Uri sessionUri);
+    public CaptureSession getSession(Uri sessionUri);
 
     /**
      * Add a listener to be informed about capture session updates.
index 50635bb..fb25765 100644 (file)
@@ -20,7 +20,6 @@ import android.graphics.Bitmap;
 import android.location.Location;
 import android.net.Uri;
 
-import com.android.camera.app.MediaSaver;
 import com.android.camera.async.MainThread;
 import com.android.camera.debug.Log;
 
@@ -61,13 +60,9 @@ import java.util.Map;
  */
 public class CaptureSessionManagerImpl implements CaptureSessionManager {
     private static final Log.Tag TAG = new Log.Tag("CaptureSessMgrImpl");
-    /** Sub-directory for storing temporary session files. */
-    private static final String TEMP_SESSIONS = "TEMP_SESSIONS";
 
-    private final MediaSaver mMediaSaver;
-    private final PlaceholderManager mPlaceholderManager;
+    private final CaptureSessionFactory mSessionFactory;
     private final SessionStorageManager mSessionStorageManager;
-    private final StackSaverFactory mStackSaverFactory;
 
     /** Failed session messages. Uri -> message. */
     private final HashMap<Uri, CharSequence> mFailedSessionMessages = new HashMap<>();
@@ -86,31 +81,26 @@ public class CaptureSessionManagerImpl implements CaptureSessionManager {
     /**
      * Initializes a new {@link CaptureSessionManager} implementation.
      *
-     * @param mediaSaver used to store the resulting media item
-     * @param placeholderManager used to manage placeholders in the filmstrip
-     *            before the final result is ready
+     * @param sessionFactory used to create new capture session objects.
      * @param sessionStorageManager used to tell modules where to store
      *            temporary session data
+     * @param mainHandler the main handler which listener callback is executed on.
      */
-    public CaptureSessionManagerImpl(MediaSaver mediaSaver, PlaceholderManager placeholderManager,
-            SessionStorageManager sessionStorageManager, StackSaverFactory stackSaverProvider,
+    public CaptureSessionManagerImpl(
+            CaptureSessionFactory sessionFactory,
+            SessionStorageManager sessionStorageManager,
             MainThread mainHandler) {
+        mSessionFactory = sessionFactory;
         mSessions = new HashMap<>();
-        mMediaSaver = mediaSaver;
-        mPlaceholderManager = placeholderManager;
         mSessionStorageManager = sessionStorageManager;
-        mStackSaverFactory = stackSaverProvider;
         mMainHandler = mainHandler;
     }
 
-    @Override
-    public CaptureSession createNewSession(String title, long sessionStartTime, Location location) {
-        TemporarySessionFile temporarySessionFile = new TemporarySessionFile(
-                mSessionStorageManager, TEMP_SESSIONS, title);
-        return new CaptureSessionImpl(title, sessionStartTime, location, temporarySessionFile,
-                this, mPlaceholderManager, mMediaSaver, mStackSaverFactory.create(title, location));
+    public CaptureSession createNewSession(String title, long sessionStartMillis, Location location) {
+        return mSessionFactory.createNewSession(this, title, sessionStartMillis, location);
     }
 
+
     @Override
     public void putSession(Uri sessionUri, CaptureSession session) {
         synchronized (mSessions) {