Android-x86
Fork
Donation

  • R/O
  • HTTP
  • SSH
  • HTTPS

packages-apps-Camera2: Commit

packages/apps/Camera2


Commit MetaInfo

Revision5a9bb34c375088aae9d12eb316141b891ec73f0f (tree)
Time2020-02-19 13:01:08
Authorhenryhsu <henryhsu@goog...>
CommiterLiu Xiaoxu

Log Message

Fix camera facing by querying characteristics

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)

Change Summary

Incremental Difference

--- a/src/com/android/camera/CaptureModule.java
+++ b/src/com/android/camera/CaptureModule.java
@@ -1537,12 +1537,10 @@ public class CaptureModule extends CameraModule implements
15371537
15381538 /**
15391539 * Returns which way around the camera is facing, based on it's ID.
1540- * <p>
1541- * TODO: This needs to change so that we store the direction directly in the
1542- * settings, rather than a Camera ID.
15431540 */
1544- private static Facing getFacingFromCameraId(int cameraId) {
1545- return cameraId == 1 ? Facing.FRONT : Facing.BACK;
1541+ private Facing getFacingFromCameraId(int cameraId) {
1542+ return mAppController.getCameraProvider().getCharacteristics(cameraId)
1543+ .isFacingFront() ? Facing.FRONT : Facing.BACK;
15461544 }
15471545
15481546 private void resetTextureBufferSize() {
--- a/src/com/android/camera/DisableCameraReceiver.java
+++ b/src/com/android/camera/DisableCameraReceiver.java
@@ -30,7 +30,7 @@ import com.android.camera.debug.Log;
3030 // this receiver will be disabled, so it will not run again.
3131 public class DisableCameraReceiver extends BroadcastReceiver {
3232 private static final Log.Tag TAG = new Log.Tag("DisableCamRcver");
33- private static final boolean CHECK_BACK_CAMERA_ONLY = true;
33+ private static final boolean CHECK_BACK_CAMERA_ONLY = false;
3434 private static final String ACTIVITIES[] = {
3535 "com.android.camera.CameraLauncher",
3636 };
--- a/src/com/android/camera/captureintent/resource/ResourceConstructedImpl.java
+++ b/src/com/android/camera/captureintent/resource/ResourceConstructedImpl.java
@@ -76,7 +76,7 @@ public final class ResourceConstructedImpl implements ResourceConstructed {
7676 AppController appController,
7777 FatalErrorHandler fatalErrorHandler) {
7878 final CameraFacingSetting cameraFacingSetting = new CameraFacingSetting(
79- context.getResources(), settingsManager, settingScopeNamespace);
79+ context.getResources(), settingsManager, settingScopeNamespace, appController);
8080 final ResolutionSetting resolutionSetting = new ResolutionSetting(
8181 settingsManager, oneCameraManager, context.getContentResolver());
8282 return new RefCountBase<ResourceConstructed>(new ResourceConstructedImpl(
--- a/src/com/android/camera/settings/CameraFacingSetting.java
+++ b/src/com/android/camera/settings/CameraFacingSetting.java
@@ -16,6 +16,7 @@
1616
1717 package com.android.camera.settings;
1818
19+import com.android.camera.app.AppController;
1920 import com.android.camera.CameraActivity;
2021 import com.android.camera.one.OneCamera;
2122 import com.android.camera2.R;
@@ -40,18 +41,24 @@ public class CameraFacingSetting {
4041 public CameraFacingSetting(
4142 Resources resources,
4243 SettingsManager settingsManager,
43- String moduleSettingScope) {
44+ String moduleSettingScope,
45+ AppController appController) {
4446 mSettingsManager = settingsManager;
4547
4648 mSettingScope = SettingsManager.getModuleSettingScope(moduleSettingScope);
4749
4850 mCameraFacingSettingKey = Keys.KEY_CAMERA_ID;
49- mCameraFacingBackValue =
50- Integer.parseInt(resources.getString(R.string.pref_camera_id_entry_back_value));
51- mCameraFacingFrontValue =
52- Integer.parseInt(resources.getString(R.string.pref_camera_id_entry_front_value));
5351 mCameraFacingDefaultValue =
5452 Integer.parseInt(resources.getString(R.string.pref_camera_id_default));
53+
54+ if (appController.getCameraProvider().getCharacteristics(mCameraFacingDefaultValue).
55+ isFacingFront()) {
56+ mCameraFacingFrontValue = 0;
57+ mCameraFacingBackValue = 1;
58+ } else {
59+ mCameraFacingBackValue = 0;
60+ mCameraFacingFrontValue = 1;
61+ }
5562 }
5663
5764 @Override
Show on old repository browser