Query facing from characteristics instead of hard coded.
Some code like camera_id_icons still assume the back camera id is
0. But these codes are only used when switching cameras. If there
is only one camera (either front or back), camera app works fine.
If there are two cameras, back camera id should be 0.
Also changing CHECK_BACK_CAMERA_ONLY to false because some devices
only have a front camera.
BUG=
27516910
TEST=manually run camera app on device
Change-Id: I9f6914e2eb7609a6cb7eb840e3e27e440a7c81df
(cherry picked from commit
daa06b80d28adfccfb785b8fa9b73898af50579b)
/**
* Returns which way around the camera is facing, based on it's ID.
- * <p>
- * TODO: This needs to change so that we store the direction directly in the
- * settings, rather than a Camera ID.
*/
- private static Facing getFacingFromCameraId(int cameraId) {
- return cameraId == 1 ? Facing.FRONT : Facing.BACK;
+ private Facing getFacingFromCameraId(int cameraId) {
+ return mAppController.getCameraProvider().getCharacteristics(cameraId)
+ .isFacingFront() ? Facing.FRONT : Facing.BACK;
}
private void resetTextureBufferSize() {
// this receiver will be disabled, so it will not run again.
public class DisableCameraReceiver extends BroadcastReceiver {
private static final Log.Tag TAG = new Log.Tag("DisableCamRcver");
- private static final boolean CHECK_BACK_CAMERA_ONLY = true;
+ private static final boolean CHECK_BACK_CAMERA_ONLY = false;
private static final String ACTIVITIES[] = {
"com.android.camera.CameraLauncher",
};
AppController appController,
FatalErrorHandler fatalErrorHandler) {
final CameraFacingSetting cameraFacingSetting = new CameraFacingSetting(
- context.getResources(), settingsManager, settingScopeNamespace);
+ context.getResources(), settingsManager, settingScopeNamespace, appController);
final ResolutionSetting resolutionSetting = new ResolutionSetting(
settingsManager, oneCameraManager, context.getContentResolver());
return new RefCountBase<ResourceConstructed>(new ResourceConstructedImpl(
package com.android.camera.settings;
+import com.android.camera.app.AppController;
import com.android.camera.CameraActivity;
import com.android.camera.one.OneCamera;
import com.android.camera2.R;
public CameraFacingSetting(
Resources resources,
SettingsManager settingsManager,
- String moduleSettingScope) {
+ String moduleSettingScope,
+ AppController appController) {
mSettingsManager = settingsManager;
mSettingScope = SettingsManager.getModuleSettingScope(moduleSettingScope);
mCameraFacingSettingKey = Keys.KEY_CAMERA_ID;
- mCameraFacingBackValue =
- Integer.parseInt(resources.getString(R.string.pref_camera_id_entry_back_value));
- mCameraFacingFrontValue =
- Integer.parseInt(resources.getString(R.string.pref_camera_id_entry_front_value));
mCameraFacingDefaultValue =
Integer.parseInt(resources.getString(R.string.pref_camera_id_default));
+
+ if (appController.getCameraProvider().getCharacteristics(mCameraFacingDefaultValue).
+ isFacingFront()) {
+ mCameraFacingFrontValue = 0;
+ mCameraFacingBackValue = 1;
+ } else {
+ mCameraFacingBackValue = 0;
+ mCameraFacingFrontValue = 1;
+ }
}
@Override