xie
2024-11-23 3fdfdea0721fe7a36f6aaa509075f01a194f6748
android/packages/apps/Camera2/src/com/android/camera/MultiToggleImageButton.java
....@@ -27,6 +27,7 @@
2727 import android.graphics.Matrix;
2828 import android.graphics.drawable.Drawable;
2929 import android.os.AsyncTask;
30
+import android.os.SystemProperties;
3031 import android.util.AttributeSet;
3132 import android.view.View;
3233 import android.widget.ImageButton;
....@@ -74,6 +75,8 @@
7475 private int mAnimDirection;
7576 private Matrix mMatrix = new Matrix();
7677 private ValueAnimator mAnimator;
78
+
79
+ private static final String ANDROID_UVC_PROPERTY = "ro.camera.uvcfacing";
7780
7881 public MultiToggleImageButton(Context context) {
7982 super(context);
....@@ -242,6 +245,37 @@
242245
243246 private void nextState() {
244247 int state = mState + 1;
248
+ if(getId() == R.id.camera_toggle_button){
249
+ /*
250
+ *If ro.camera.uvcfacing is set, then skip the original facing state.
251
+ */
252
+ String uvcProperty = SystemProperties.get(ANDROID_UVC_PROPERTY, "");
253
+ if(uvcProperty.equals("")){
254
+ if(state == Integer.parseInt(getResources()
255
+ .getString(R.string.pref_camera_id_entry_external_value))){
256
+ state = state + 1;
257
+ }
258
+ }
259
+ else if (uvcProperty.equals("back")) {
260
+ if(state == Integer.parseInt(getResources()
261
+ .getString(R.string.pref_camera_id_entry_back_value))){
262
+ state = state + 1;
263
+ }
264
+ }
265
+ else if (uvcProperty.equals("front")) {
266
+ if(state == Integer.parseInt(getResources()
267
+ .getString(R.string.pref_camera_id_entry_front_value))){
268
+ state = state + 1;
269
+ }
270
+ }
271
+ else if (uvcProperty.equals("external")) {
272
+ int externalValue = Integer.parseInt(getResources().
273
+ getString(R.string.pref_camera_id_entry_external_value));
274
+ if(state != externalValue){
275
+ state = externalValue;
276
+ }
277
+ }
278
+ }
245279 if (state >= mImageIds.length) {
246280 state = 0;
247281 }