2 * Copyright (C) 2015 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package com.android.camera.captureintent;
19 import com.android.camera.app.MediaSaver;
20 import com.android.camera.debug.Log;
21 import com.android.camera.exif.ExifInterface;
22 import com.android.camera.session.CaptureSession;
23 import com.android.camera.session.CaptureSessionManager;
24 import com.android.camera.session.SessionNotifier;
25 import com.android.camera.session.StackSaver;
26 import com.android.camera.session.TemporarySessionFile;
27 import com.android.camera.stats.CaptureSessionStatsCollector;
28 import com.android.camera.util.Size;
30 import android.graphics.Bitmap;
31 import android.location.Location;
32 import android.net.Uri;
35 * An implementation of {@link CaptureSession} which is used by
36 * {@link CaptureIntentModule}.
38 public class CaptureIntentSession implements CaptureSession {
39 private static final Log.Tag TAG = new Log.Tag("CapIntSession");
41 /** For aggregation of capture information */
42 // TODO: Implement mCaptureSessionStatsCollector.decorateAtTimeCaptureRequest call.
43 private final CaptureSessionStatsCollector mCaptureSessionStatsCollector =
44 new CaptureSessionStatsCollector();
45 /** The capture session manager responsible for this session. */
46 private final CaptureSessionManager mSessionManager;
47 /** Used to inform about session status updates. */
48 private final SessionNotifier mSessionNotifier;
49 /** The title of the item being processed. */
50 private final String mTitle;
51 /** The location this session was created at. Used for media store. */
52 private Location mLocation;
53 /** Whether one of start methods are called. */
54 private boolean isStarted;
57 * Creates a new {@link CaptureSession}.
59 * @param title the title of this session.
60 * @param location the location of this session, used for media store.
61 * @param captureSessionManager the capture session manager responsible for
64 public CaptureIntentSession(String title, Location location,
65 CaptureSessionManager captureSessionManager, SessionNotifier sessionNotifier) {
68 mSessionManager = captureSessionManager;
69 mSessionNotifier = sessionNotifier;
74 public String getTitle() {
79 public Location getLocation() {
84 public void setLocation(Location location) {
88 // TODO: Support progress in the future once HDR is enabled for capture intent.
90 public synchronized int getProgress() {
95 public synchronized void setProgress(int percent) {
100 public synchronized int getProgressMessageId() {
105 public synchronized void setProgressMessage(int messageId) {
109 public void updateThumbnail(Bitmap bitmap) {
110 mSessionNotifier.notifySessionThumbnailAvailable(bitmap);
114 public void updateCaptureIndicatorThumbnail(Bitmap indicator, int rotationDegrees) {
119 public synchronized void startEmpty(Size pictureSize) {
124 public synchronized void startSession(Bitmap placeholder, int progressMessageId) {
125 throw new RuntimeException("Not supported.");
129 public synchronized void startSession(byte[] placeholder, int progressMessageId) {
130 throw new RuntimeException("Not supported.");
134 public synchronized void startSession(Uri uri, int progressMessageId) {
135 throw new RuntimeException("Not supported.");
139 public synchronized void cancel() {
143 public synchronized void saveAndFinish(byte[] data, int width, int height, int orientation,
144 ExifInterface exif, final MediaSaver.OnMediaSavedListener listener) {
145 mSessionNotifier.notifySessionPictureDataAvailable(data, orientation);
149 public StackSaver getStackSaver() {
154 public void finish() {
159 public TemporarySessionFile getTempOutputFile() {
160 throw new RuntimeException("Not supported.");
164 public Uri getUri() {
165 throw new RuntimeException("Not supported.");
169 public void updatePreview() {
170 throw new RuntimeException("Not supported.");
174 public void finishWithFailure(int progressMessageId, boolean removeFromFilmstrip) {
175 throw new RuntimeException("Not supported.");
179 public void finalizeSession() {
184 public void addProgressListener(CaptureSession.ProgressListener listener) {
189 public void removeProgressListener(CaptureSession.ProgressListener listener) {
194 public CaptureSessionStatsCollector getCollector() {
195 return mCaptureSessionStatsCollector;
198 private boolean isStarted() {