Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 53073482 authored by Angus Kong's avatar Angus Kong
Browse files

Refactor CameraManager.

1. CameraManager should be the only class accessing android.hardware.Camera.
2. For potential future upgrade in Camera HAL and android.hardward.Camera API
   upgrade, CameraManager should be just an interface instead of concrete
   implementation.
3. waitDone() in CameraProxy is removed.
4. ShutterCallback, PreviewCallback, PictureCallback and AF Callbacks are
   wrapped by our own interfaces.

Change-Id: I595da17a1a9c6d476ee805b71c7f45ebb609e465
parent 554e6be1
Loading
Loading
Loading
Loading
+737 −0

File added.

Preview size limit exceeded, changes collapsed.

+2 −1
Original line number Diff line number Diff line
@@ -207,7 +207,8 @@ public class CameraHolder {
            try {
                Log.v(TAG, "open camera " + cameraId);
                if (mMockCameraInfo == null) {
                    mCameraDevice = CameraManager.instance().cameraOpen(cameraId);
                    mCameraDevice = CameraManagerFactory
                            .getAndroidCameraManager().cameraOpen(cameraId);
                } else {
                    if (mMockCamera == null)
                        throw new RuntimeException();
+246 −424

File changed.

Preview size limit exceeded, changes collapsed.

+37 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2013 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;

/**
 * A factory class for {@link CameraManager}.
 */
public class CameraManagerFactory {

    private static AndroidCameraManagerImpl sAndroidCameraManager;

    /**
     * Returns the android camera implementation of {@link CameraManager}.
     *
     * @return The {@link CameraManager} to control the camera device.
     */
    public static synchronized CameraManager getAndroidCameraManager() {
        if (sAndroidCameraManager == null) {
            sAndroidCameraManager = new AndroidCameraManagerImpl();
        }
        return sAndroidCameraManager;
    }
}
+4 −5
Original line number Diff line number Diff line
@@ -30,7 +30,6 @@ import com.android.gallery3d.R;
import com.android.gallery3d.common.ApiHelper;

import java.io.FileDescriptor;
import java.io.IOException;
import java.io.Serializable;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationHandler;
@@ -650,7 +649,7 @@ public class EffectsRecorder {
                // Switching effects while running. Stop existing runner.
                // The stop callback will take care of starting new runner.
                mCameraDevice.stopPreview();
                mCameraDevice.setPreviewTextureAsync(null);
                mCameraDevice.setPreviewTexture(null);
                invoke(mOldRunner, sGraphRunnerStop);
            }
        }
@@ -862,9 +861,9 @@ public class EffectsRecorder {

            mCameraDevice.stopPreview();
            if (mLogVerbose) Log.v(TAG, "Runner active, connecting effects preview");
            mCameraDevice.setPreviewTextureAsync(mTextureSource);
            mCameraDevice.setPreviewTexture(mTextureSource);

            mCameraDevice.startPreviewAsync();
            mCameraDevice.startPreview();

            // Unlock AE/AWB after preview started
            tryEnable3ALocks(false);
@@ -995,7 +994,7 @@ public class EffectsRecorder {
            return;
        }
        mCameraDevice.stopPreview();
        mCameraDevice.setPreviewTextureAsync(null);
        mCameraDevice.setPreviewTexture(null);
    }

    // Stop and release effect resources
Loading