.. | .. |
---|
68 | 68 | <string name="error_cannot_connect_camera" msgid="2713059773224193128">"无法连接到相机。"</string> |
---|
69 | 69 | <string name="error_camera_disabled" msgid="5582398275657419692">"由于安全规范的限制,相机已被禁用。"</string> |
---|
70 | 70 | <string name="error_media_storage_failure" msgid="7711687330673245629">"保存您的照片或视频时出现问题。"</string> |
---|
| 71 | + <string name="error_cannot_start_recording_failur">"录像异常,当前设备不支持该录像参数"</string> |
---|
71 | 72 | <string name="error_permissions" msgid="3454167403425651254">"此应用缺少运行所需的必要权限。请检查您的权限设置。"</string> |
---|
72 | 73 | <string name="reason_storage_failure" msgid="6818898304774654969">"照片存储失败。"</string> |
---|
73 | 74 | <string name="wait" msgid="765601745709933047">"请稍候…"</string> |
---|
.. | .. |
---|
77 | 78 | <string name="time_lapse_title" msgid="3267978566401228497">"延时录影"</string> |
---|
78 | 79 | <string name="feedback_description_camera_access" msgid="419090951070170132">"该应用无法连接到相机"</string> |
---|
79 | 80 | <string name="feedback_description_save_photo" msgid="8658767358989083228">"照片或视频没有保存到设备中。"</string> |
---|
| 81 | + <string name="feedback_description_start_recording">无法启动录像</string> |
---|
80 | 82 | <string name="capturing" msgid="5255164204641920893">"正在拍摄"</string> |
---|
81 | 83 | <string name="pref_camera_id_title" msgid="4680648115225411185">"选择摄像头"</string> |
---|
82 | 84 | <string name="pref_camera_id_entry_back" msgid="6386943973628160510">"后置"</string> |
---|
83 | 85 | <string name="pref_camera_id_entry_front" msgid="6233067010315787044">"前置"</string> |
---|
| 86 | + <string name="pref_camera_id_entry_external" msgid="6233067010315787044">"外置"</string> |
---|
84 | 87 | <string name="pref_camera_save_location_title" msgid="2344235620113384017">"保存位置信息"</string> |
---|
85 | 88 | <string name="pref_camera_location_label" msgid="8695441802378057719">"位置信息"</string> |
---|
86 | 89 | <string name="pref_camera_timer_title" msgid="4728838281741571323">"倒计时器"</string> |
---|
.. | .. |
---|
156 | 159 | <string name="pref_camera_hdr_label" msgid="1918040375414771185">"HDR"</string> |
---|
157 | 160 | <string name="pref_camera_id_label_back" msgid="1645608049757733858">"前置摄像头"</string> |
---|
158 | 161 | <string name="pref_camera_id_label_front" msgid="349308803062874842">"后置摄像头"</string> |
---|
| 162 | + <string name="pref_camera_id_label_external" msgid="349308803062874842">"USB外置摄像头"</string> |
---|
159 | 163 | <string name="dialog_ok" msgid="774141340500181131">"确定"</string> |
---|
160 | 164 | <string name="dialog_cancel" msgid="692365061128351656">"取消"</string> |
---|
161 | 165 | <string name="dialog_report" msgid="7616428760369876209">"报告"</string> |
---|
.. | .. |
---|
319 | 323 | <string name="torch_off_desc" msgid="8304675202998742618">"手电筒已关闭"</string> |
---|
320 | 324 | <string name="camera_id_back_desc" msgid="3566327490758890635">"后置摄像头"</string> |
---|
321 | 325 | <string name="camera_id_front_desc" msgid="7497517948130254220">"前置摄像头"</string> |
---|
| 326 | + <string name="camera_id_external_desc" msgid="7497517948130254220">"USB外置摄像头"</string> |
---|
322 | 327 | <string name="grid_lines_off_desc" msgid="2022385817190451353">"网格线已关闭"</string> |
---|
323 | 328 | <string name="grid_lines_on_desc" msgid="4601540461914364817">"网格线已开启"</string> |
---|
324 | 329 | <string name="countdown_timer_off" msgid="1663008439564495948">"倒计时器已关闭"</string> |
---|
.. | .. |
---|
345 | 350 | <string name="setting_back_camera_video" msgid="5220819479408164689">"后置摄像头视频"</string> |
---|
346 | 351 | <string name="setting_front_camera_photo" msgid="4131886734622868637">"前置摄像头照片"</string> |
---|
347 | 352 | <string name="setting_front_camera_video" msgid="2178799452805359752">"前置摄像头视频"</string> |
---|
| 353 | + <string name="setting_external_camera_photo" msgid="4131886734622868637">"USB外置摄像头照片"</string> |
---|
| 354 | + <string name="setting_external_camera_video" msgid="2178799452805359752">"USB外置摄像头视频"</string> |
---|
348 | 355 | <string name="setting_default_camera" msgid="6954076799301004779">"默认相机"</string> |
---|
349 | 356 | <string name="setting_google_help_and_feedback" msgid="2079580537079242775">"帮助和反馈"</string> |
---|
350 | 357 | <string name="processing_hdr_plus" msgid="9160093263037540304">"正在处理HDR+…"</string> |
---|
old mode 100755new mode 100644.. | .. |
---|
190 | 190 | <item>@drawable/ic_switch_camera_external</item> |
---|
191 | 191 | </array> |
---|
192 | 192 | |
---|
193 | | - <array name="camera_id_icons_without_external" translatable="false"> |
---|
194 | | - <item>@drawable/ic_switch_camera_back</item> |
---|
195 | | - <item>@drawable/ic_switch_camera_front</item> |
---|
196 | | - </array> |
---|
197 | | - |
---|
198 | 193 | <array name="camera_id_icons_with_external" translatable="false"> |
---|
199 | 194 | <item>@drawable/ic_switch_camera_back</item> |
---|
200 | 195 | <item>@drawable/ic_switch_camera_front</item> |
---|
201 | 196 | <item>@drawable/ic_switch_camera_external</item> |
---|
202 | 197 | </array> |
---|
203 | 198 | |
---|
204 | | - <array name="camera_id_icons_with_front_external" translatable="false"> |
---|
| 199 | + <array name="camera_id_icons_with_double_external" translatable="false"> |
---|
| 200 | + <item>@drawable/ic_switch_camera_back</item> |
---|
| 201 | + <item>@drawable/ic_switch_camera_front</item> |
---|
| 202 | + <item>@drawable/ic_switch_camera_external</item> |
---|
| 203 | + <item>@drawable/ic_switch_camera_external</item> |
---|
| 204 | + </array> |
---|
| 205 | + |
---|
| 206 | + <array name="camera_id_icons_external_double" translatable="false"> |
---|
| 207 | + <item>@drawable/ic_switch_camera_external</item> |
---|
| 208 | + <item>@drawable/ic_switch_camera_external</item> |
---|
| 209 | + </array> |
---|
| 210 | + |
---|
| 211 | + <array name="camera_id_icon_back_with_external" translatable="false"> |
---|
205 | 212 | <item>@drawable/ic_switch_camera_back</item> |
---|
206 | 213 | <item>@drawable/ic_switch_camera_external</item> |
---|
207 | 214 | </array> |
---|
208 | 215 | |
---|
209 | | - <array name="camera_id_icons_with_back_external" translatable="false"> |
---|
| 216 | + <array name="camera_id_icon_back_with_double_external" translatable="false"> |
---|
| 217 | + <item>@drawable/ic_switch_camera_back</item> |
---|
| 218 | + <item>@drawable/ic_switch_camera_external</item> |
---|
| 219 | + <item>@drawable/ic_switch_camera_external</item> |
---|
| 220 | + </array> |
---|
| 221 | + |
---|
| 222 | + <array name="camera_id_icon_front" translatable="false"> |
---|
210 | 223 | <item>@drawable/ic_switch_camera_front</item> |
---|
211 | 224 | <item>@drawable/ic_switch_camera_external</item> |
---|
212 | 225 | </array> |
---|
213 | 226 | |
---|
214 | | - <array name="camera_id_icons_with_only_external" translatable="false"> |
---|
| 227 | + <array name="camera_id_icon_front_with_external" translatable="false"> |
---|
| 228 | + <item>@drawable/ic_switch_camera_front</item> |
---|
| 229 | + <item>@drawable/ic_switch_camera_external</item> |
---|
| 230 | + </array> |
---|
| 231 | + |
---|
| 232 | + <array name="camera_id_icon_front_with_double_external" translatable="false"> |
---|
| 233 | + <item>@drawable/ic_switch_camera_front</item> |
---|
| 234 | + <item>@drawable/ic_switch_camera_external</item> |
---|
215 | 235 | <item>@drawable/ic_switch_camera_external</item> |
---|
216 | 236 | </array> |
---|
217 | 237 | |
---|
.. | .. |
---|
220 | 240 | <item>@string/camera_id_front_desc</item> |
---|
221 | 241 | <item>@string/camera_id_external_desc</item> |
---|
222 | 242 | </array> |
---|
223 | | - |
---|
224 | 243 | |
---|
225 | 244 | <array name="camera_id_largeicons" translatable="false"> |
---|
226 | 245 | <item>@drawable/ic_switch_camera_back</item> |
---|
.. | .. |
---|
136 | 136 | <!-- message for the dialog showing that the user's photo could not be saved [CHAR LIMIT=NONE] --> |
---|
137 | 137 | <string name="error_media_storage_failure">There was a problem saving your photo or video.</string> |
---|
138 | 138 | |
---|
| 139 | + <!-- message for the dialog showing that the user's photo could not be saved [CHAR LIMIT=NONE] --> |
---|
| 140 | + <string name="error_cannot_start_recording_failure">The recording parameters are not compatible with this camera.</string> |
---|
| 141 | + |
---|
139 | 142 | <!-- message for the dialog showing that the app does not have sufficient permissions [CHAR LIMIT=NONE] --> |
---|
140 | 143 | <string name="error_permissions">The app does not have critical permissions needed to run. Please check your permissions settings.</string> |
---|
141 | 144 | |
---|
.. | .. |
---|
163 | 166 | <!-- Default feedback that is entered in the Feedback textview for issues related to saving photos. [CHAR LIMIT=NONE] --> |
---|
164 | 167 | <string name="feedback_description_save_photo">Photo or video did not save to the device.</string> |
---|
165 | 168 | |
---|
| 169 | + <!-- Default feedback that is entered in the Feedback textview for issues related to recording. [CHAR LIMIT=NONE] --> |
---|
| 170 | + <string name="feedback_description_start_recording">Can not start recording because of video settings</string> |
---|
| 171 | + |
---|
166 | 172 | <!-- Screen display message during image capture to indicate that the capture is in progress, like during HDR+. [CHAR LIMIT=20] --> |
---|
167 | 173 | <string name="capturing">Capturing</string> |
---|
168 | 174 | |
---|
.. | .. |
---|
172 | 178 | <string name="pref_camera_id_default" translatable="false">0</string> |
---|
173 | 179 | |
---|
174 | 180 | <!-- Named indexes into the array of camera facing entries --> |
---|
| 181 | + <!--string name="pref_camera_id_index_back" translatable="false">1</string> |
---|
| 182 | + <string name="pref_camera_id_index_front" translatable="false">2</string--> |
---|
| 183 | + |
---|
175 | 184 | <string name="pref_camera_id_index_back" translatable="false">1</string> |
---|
176 | 185 | <string name="pref_camera_id_index_front" translatable="false">2</string> |
---|
177 | 186 | <string name="pref_camera_id_index_external" translatable="false">2</string> |
---|
.. | .. |
---|
840 | 849 | <string name="setting_front_camera_photo">Front camera photo</string> |
---|
841 | 850 | <!-- Camera settings title for front camera video resolution. [CHAR LIMIT=25] --> |
---|
842 | 851 | <string name="setting_front_camera_video">Front camera video</string> |
---|
| 852 | + <!-- Camera settings title for external camera photo resolution. [CHAR LIMIT=25] --> |
---|
| 853 | + <string name="setting_external_camera_photo">External camera photo</string> |
---|
| 854 | + <!-- Camera settings title for external camera video resolution. [CHAR LIMIT=25] --> |
---|
| 855 | + <string name="setting_external_camera_video">External camera video</string> |
---|
843 | 856 | |
---|
844 | 857 | <!-- Text shown in camera settings list for selecting the camera mode that will be used by default when the app starts [CHAR LIMIT=25] --> |
---|
845 | 858 | <string name="setting_default_camera">Default Camera</string> |
---|
old mode 100755new mode 100644.. | .. |
---|
36 | 36 | android:entryValues="@array/pref_camera_picturesize_entryvalues" |
---|
37 | 37 | android:key="pref_camera_picturesize_front_key" |
---|
38 | 38 | android:title="@string/setting_front_camera_photo" /> |
---|
| 39 | + <!-- EXTERNAL camera PHOTO resolution --> |
---|
| 40 | + <ListPreference |
---|
| 41 | + android:defaultValue="@string/pref_camera_picturesize_default" |
---|
| 42 | + android:entryValues="@array/pref_camera_picturesize_entryvalues" |
---|
| 43 | + android:key="pref_camera_picturesize_external_key" |
---|
| 44 | + android:title="@string/setting_external_camera_photo" /> |
---|
39 | 45 | </PreferenceCategory> |
---|
40 | 46 | <PreferenceCategory android:title="@string/mode_video" > |
---|
41 | 47 | |
---|
.. | .. |
---|
51 | 57 | android:entryValues="@array/pref_video_quality_entryvalues" |
---|
52 | 58 | android:key="pref_video_quality_front_key" |
---|
53 | 59 | android:title="@string/setting_front_camera_video" /> |
---|
| 60 | + <!-- EXTERNAL camera VIDEO resolution --> |
---|
| 61 | + <ListPreference |
---|
| 62 | + android:defaultValue="@string/pref_video_quality_small" |
---|
| 63 | + android:entryValues="@array/pref_video_quality_entryvalues" |
---|
| 64 | + android:key="pref_video_quality_external_key" |
---|
| 65 | + android:title="@string/setting_external_camera_video" /> |
---|
54 | 66 | </PreferenceCategory> |
---|
55 | 67 | </PreferenceScreen> |
---|
56 | 68 | |
---|
old mode 100755new mode 100644.. | .. |
---|
33 | 33 | import com.android.camera.widget.ModeOptions; |
---|
34 | 34 | import com.android.camera2.R; |
---|
35 | 35 | |
---|
| 36 | +import android.util.Log; |
---|
| 37 | +import android.hardware.camera2.CameraManager; |
---|
| 38 | +import android.hardware.camera2.CameraAccessException; |
---|
| 39 | +import android.hardware.camera2.CameraCharacteristics; |
---|
| 40 | +import com.android.camera.one.OneCamera.Facing; |
---|
| 41 | + |
---|
36 | 42 | /** |
---|
37 | 43 | * A class for generating pre-initialized |
---|
38 | 44 | * {@link #android.widget.ImageButton}s. |
---|
.. | .. |
---|
51 | 57 | public static final int BUTTON_GRID_LINES = 10; |
---|
52 | 58 | public static final int BUTTON_EXPOSURE_COMPENSATION = 11; |
---|
53 | 59 | public static final int BUTTON_COUNTDOWN = 12; |
---|
| 60 | + |
---|
| 61 | + public static final int ZERO_CAMERA = 0; |
---|
| 62 | + public static final int ONE_CAMERA = 1; |
---|
| 63 | + public static final int TWO_CAMERAS = 2; |
---|
54 | 64 | |
---|
55 | 65 | /** For two state MultiToggleImageButtons, the off index. */ |
---|
56 | 66 | public static final int OFF = 0; |
---|
.. | .. |
---|
101 | 111 | |
---|
102 | 112 | private final AppController mAppController; |
---|
103 | 113 | |
---|
104 | | - private static final String ANDROID_UVC_PROPERTY = "ro.camera.uvcfacing"; |
---|
| 114 | + private CameraManager mCameraManager; |
---|
| 115 | + private static String TAG = "ButtonManager"; |
---|
105 | 116 | |
---|
106 | 117 | /** |
---|
107 | 118 | * Get a new global ButtonManager. |
---|
.. | .. |
---|
114 | 125 | |
---|
115 | 126 | mSettingsManager = app.getSettingsManager(); |
---|
116 | 127 | mSettingsManager.addListener(this); |
---|
| 128 | + mCameraManager = (CameraManager) context.getSystemService(Context.CAMERA_SERVICE); |
---|
117 | 129 | } |
---|
118 | 130 | |
---|
119 | 131 | /** |
---|
.. | .. |
---|
361 | 373 | initializeHdrPlusFlashButton(button, cb, preCb, R.array.camera_flashmode_icons); |
---|
362 | 374 | break; |
---|
363 | 375 | case BUTTON_CAMERA: |
---|
364 | | - String uvcProperty = SystemProperties.get(ANDROID_UVC_PROPERTY, ""); |
---|
365 | | - if(uvcProperty.equals("null") || uvcProperty.equals("")){ |
---|
366 | | - initializeCameraButton(button, cb, |
---|
367 | | - preCb, R.array.camera_id_icons); |
---|
| 376 | + String[] cameraIds = new String[]{}; |
---|
| 377 | + int front_num = 0; |
---|
| 378 | + int back_num = 0; |
---|
| 379 | + int external_num = 0; |
---|
| 380 | + try { |
---|
| 381 | + cameraIds = mCameraManager.getCameraIdList(); |
---|
| 382 | + for (String cameraId : cameraIds) { |
---|
| 383 | + CameraCharacteristics characteristics = mCameraManager |
---|
| 384 | + .getCameraCharacteristics(cameraId); |
---|
| 385 | + if (characteristics.get(CameraCharacteristics.LENS_FACING) == |
---|
| 386 | + CameraCharacteristics.LENS_FACING_FRONT) { |
---|
| 387 | + front_num = front_num + 1; |
---|
| 388 | + } else if (characteristics.get(CameraCharacteristics.LENS_FACING) == |
---|
| 389 | + CameraCharacteristics.LENS_FACING_BACK) { |
---|
| 390 | + back_num = back_num + 1; |
---|
| 391 | + } else if (characteristics.get(CameraCharacteristics.LENS_FACING) == |
---|
| 392 | + CameraCharacteristics.LENS_FACING_EXTERNAL) { |
---|
| 393 | + external_num = external_num + 1; |
---|
| 394 | + } |
---|
| 395 | + } |
---|
368 | 396 | } |
---|
369 | | - else if (uvcProperty.equals("back")) { |
---|
370 | | - initializeCameraButton(button, cb, |
---|
371 | | - preCb, R.array.camera_id_icons_with_front_external); |
---|
| 397 | + catch (CameraAccessException ex) { |
---|
| 398 | + Log.e(TAG, "Unable to read camera list.", ex); |
---|
372 | 399 | } |
---|
373 | | - else if (uvcProperty.equals("front")) { |
---|
374 | | - initializeCameraButton(button, cb, |
---|
375 | | - preCb, R.array.camera_id_icons_with_back_external); |
---|
| 400 | + if (front_num == ONE_CAMERA && back_num == ZERO_CAMERA) { |
---|
| 401 | + if (external_num == ONE_CAMERA) { |
---|
| 402 | + initializeCameraButton(button, cb, |
---|
| 403 | + preCb, R.array.camera_id_icon_front_with_external); |
---|
| 404 | + } else if (external_num == TWO_CAMERAS) { |
---|
| 405 | + initializeCameraButton(button, cb, |
---|
| 406 | + preCb, R.array.camera_id_icon_front_with_double_external); |
---|
| 407 | + } |
---|
| 408 | + } else if (front_num == ZERO_CAMERA && back_num == ONE_CAMERA) { |
---|
| 409 | + if (external_num == ONE_CAMERA) { |
---|
| 410 | + initializeCameraButton(button, cb, |
---|
| 411 | + preCb, R.array.camera_id_icon_back_with_external); |
---|
| 412 | + } else if (external_num == TWO_CAMERAS) { |
---|
| 413 | + initializeCameraButton(button, cb, |
---|
| 414 | + preCb, R.array.camera_id_icon_back_with_double_external); |
---|
| 415 | + } |
---|
| 416 | + } else if (front_num == ONE_CAMERA && back_num == ONE_CAMERA) { |
---|
| 417 | + if (external_num == ZERO_CAMERA) { |
---|
| 418 | + initializeCameraButton(button, cb, |
---|
| 419 | + preCb, R.array.camera_id_icons); |
---|
| 420 | + } else if (external_num == ONE_CAMERA) { |
---|
| 421 | + initializeCameraButton(button, cb, |
---|
| 422 | + preCb, R.array.camera_id_icons_with_external); |
---|
| 423 | + } else if (external_num == TWO_CAMERAS) { |
---|
| 424 | + initializeCameraButton(button, cb, |
---|
| 425 | + preCb, R.array.camera_id_icons_with_double_external); |
---|
| 426 | + } |
---|
| 427 | + } else { |
---|
| 428 | + switch (cameraIds.length) { |
---|
| 429 | + case TWO_CAMERAS: |
---|
| 430 | + initializeCameraButton(button, cb, |
---|
| 431 | + preCb, R.array.camera_id_icons_external_double); |
---|
| 432 | + break; |
---|
| 433 | + } |
---|
376 | 434 | } |
---|
377 | | - else if (uvcProperty.equals("external")) { |
---|
378 | | - initializeCameraButton(button, cb, |
---|
379 | | - preCb, R.array.camera_id_icons_with_external); |
---|
380 | | - } |
---|
381 | | - else if (uvcProperty.equals("external-only")) { |
---|
382 | | - initializeCameraButton(button, cb, |
---|
383 | | - preCb, R.array.camera_id_icons_with_only_external); |
---|
384 | | - } |
---|
| 435 | + |
---|
385 | 436 | break; |
---|
386 | 437 | case BUTTON_HDR_PLUS: |
---|
387 | 438 | initializeHdrPlusButton(button, cb, preCb, R.array.pref_camera_hdr_plus_icons); |
---|
.. | .. |
---|
23 | 23 | import android.graphics.RectF; |
---|
24 | 24 | import android.graphics.SurfaceTexture; |
---|
25 | 25 | import android.location.Location; |
---|
| 26 | +import android.hardware.camera2.CameraAccessException; |
---|
| 27 | +import android.hardware.camera2.CameraCharacteristics; |
---|
| 28 | +import android.hardware.camera2.CameraManager; |
---|
26 | 29 | import android.media.MediaActionSound; |
---|
27 | 30 | import android.net.Uri; |
---|
28 | 31 | import android.os.AsyncTask; |
---|
.. | .. |
---|
354 | 357 | public CaptureModule(AppController appController) { |
---|
355 | 358 | this(appController, false); |
---|
356 | 359 | } |
---|
| 360 | + private CameraManager mCameraManager; |
---|
357 | 361 | |
---|
358 | 362 | /** Constructs a new capture module. */ |
---|
359 | 363 | public CaptureModule(AppController appController, boolean stickyHdr) { |
---|
.. | .. |
---|
414 | 418 | mCameraHandler = new Handler(thread.getLooper()); |
---|
415 | 419 | mActivity = activity; |
---|
416 | 420 | mOneCameraOpener = mAppController.getCameraOpener(); |
---|
| 421 | + mCameraManager = (CameraManager) mContext.getSystemService(Context.CAMERA_SERVICE); |
---|
417 | 422 | |
---|
418 | 423 | try { |
---|
419 | 424 | mOneCameraManager = OneCameraModule.provideOneCameraManager(); |
---|
.. | .. |
---|
429 | 434 | Log.d(TAG,"SettingsManager cameraID = " + |
---|
430 | 435 | mSettingsManager.getInteger(mAppController.getModuleScope(), |
---|
431 | 436 | Keys.KEY_CAMERA_ID) + " facing = " + mCameraFacing); |
---|
| 437 | + |
---|
| 438 | + int cameraId = mSettingsManager.getInteger(mAppController.getModuleScope(), |
---|
| 439 | + Keys.KEY_CAMERA_ID); |
---|
| 440 | + try { |
---|
| 441 | + String[] cameraIds = mCameraManager.getCameraIdList(); |
---|
| 442 | + Log.d(TAG, "cameraIds len = " + cameraIds.length); |
---|
| 443 | + boolean foundCameraId = false; |
---|
| 444 | + for (String currentCameraId : cameraIds) { |
---|
| 445 | + Log.d(TAG,"Enumerate cameraId = " + currentCameraId); |
---|
| 446 | + if (Integer.parseInt(currentCameraId) == cameraId) { |
---|
| 447 | + Log.d(TAG, "find exists currentCameraId matches first camera id"); |
---|
| 448 | + foundCameraId = true; |
---|
| 449 | + break; |
---|
| 450 | + } |
---|
| 451 | + } |
---|
| 452 | + if (!foundCameraId && cameraIds.length > 0) { |
---|
| 453 | + cameraId = Integer.parseInt(cameraIds[0]); |
---|
| 454 | + Log.d(TAG,"cameraId sets to first id of cameraIds: " + cameraId); |
---|
| 455 | + } |
---|
| 456 | + } catch (CameraAccessException ex) { |
---|
| 457 | + Log.w(TAG, "Unable to get camera ID", ex); |
---|
| 458 | + } |
---|
| 459 | + |
---|
432 | 460 | mShowErrorAndFinish = !updateCameraCharacteristics(); |
---|
433 | 461 | if (mShowErrorAndFinish) { |
---|
434 | 462 | return; |
---|
.. | .. |
---|
1398 | 1426 | boolean useHdr = mHdrPlusEnabled && mCameraFacing == Facing.BACK; |
---|
1399 | 1427 | |
---|
1400 | 1428 | CameraId cameraId = mOneCameraManager.findFirstCameraFacing(mCameraFacing); |
---|
| 1429 | + |
---|
| 1430 | + int settingsCameraId = mSettingsManager.getInteger(mAppController.getModuleScope(), Keys.KEY_CAMERA_ID); |
---|
| 1431 | + //check if settingsCameraId exists now |
---|
| 1432 | + try { |
---|
| 1433 | + String[] cameraIds = mCameraManager.getCameraIdList(); |
---|
| 1434 | + boolean foundCameraId = false; |
---|
| 1435 | + for (String currentCameraId : cameraIds) { |
---|
| 1436 | + Log.d(TAG,"Enumerate cameraId = " + currentCameraId); |
---|
| 1437 | + if (Integer.parseInt(currentCameraId) == settingsCameraId) { |
---|
| 1438 | + Log.d(TAG, "find exists currentCameraId matches first camera id"); |
---|
| 1439 | + foundCameraId = true; |
---|
| 1440 | + if (Integer.parseInt(cameraId.getValue()) != settingsCameraId) { |
---|
| 1441 | + cameraId = CameraId.from(String.valueOf(settingsCameraId)); |
---|
| 1442 | + } |
---|
| 1443 | + break; |
---|
| 1444 | + } |
---|
| 1445 | + } |
---|
| 1446 | + if (!foundCameraId && cameraIds.length > 0) { |
---|
| 1447 | + cameraId = CameraId.from(String.valueOf(cameraIds[0])); |
---|
| 1448 | + Log.d(TAG,"cameraId sets to first id of cameraIds: " + cameraId); |
---|
| 1449 | + } |
---|
| 1450 | + } catch (CameraAccessException ex) { |
---|
| 1451 | + Log.w(TAG, "Unable to get camera ID", ex); |
---|
| 1452 | + } |
---|
1401 | 1453 | final String settingScope = SettingsManager.getCameraSettingScope(cameraId.getValue()); |
---|
1402 | 1454 | |
---|
1403 | 1455 | OneCameraCaptureSetting captureSetting; |
---|
old mode 100755new mode 100644.. | .. |
---|
48 | 48 | MEDIA_STORAGE_FAILURE( |
---|
49 | 49 | R.string.error_media_storage_failure, |
---|
50 | 50 | R.string.feedback_description_save_photo, |
---|
| 51 | + false), |
---|
| 52 | + CAMERA_VIDEO_QUALITY_FAILURE( |
---|
| 53 | + R.string.error_cannot_start_recording_failure, |
---|
| 54 | + R.string.feedback_description_start_recording, |
---|
51 | 55 | false); |
---|
52 | 56 | |
---|
53 | 57 | private final int mDialogMsgId; |
---|
.. | .. |
---|
144 | 148 | */ |
---|
145 | 149 | public void onCameraDisabledFailure(); |
---|
146 | 150 | |
---|
| 151 | + /** |
---|
| 152 | + * Handles error where the camera is fail start recording. |
---|
| 153 | + */ |
---|
| 154 | + public void onRecordingFailure(); |
---|
147 | 155 | |
---|
148 | 156 | /** |
---|
149 | 157 | * Handles a fatal error, e.g. by displaying the appropriate dialog and |
---|
old mode 100755new mode 100644.. | .. |
---|
122 | 122 | CameraUtil.showError(mActivity, reason.getDialogMsgId(), reason.getFeedbackMsgId(), |
---|
123 | 123 | finishActivity, ex); |
---|
124 | 124 | } |
---|
| 125 | + @Override |
---|
| 126 | + public void onRecordingFailure() { |
---|
| 127 | + Exception ex = new Exception(); |
---|
| 128 | + // Log a stack trace to be sure we can track the source. |
---|
| 129 | + Log.e(TAG, "Handling Camera recording Error:", ex); |
---|
| 130 | + |
---|
| 131 | + UsageStatistics.instance().cameraFailure( |
---|
| 132 | + eventprotos.CameraFailure.FailureReason.UNKNOWN_REASON, null, |
---|
| 133 | + UsageStatistics.NONE, UsageStatistics.NONE); |
---|
| 134 | + |
---|
| 135 | + Reason reason = Reason.CAMERA_VIDEO_QUALITY_FAILURE; |
---|
| 136 | + boolean finishActivity = reason.doesFinishActivity(); |
---|
| 137 | + CameraUtil.showError(mActivity, reason.getDialogMsgId(), reason.getFeedbackMsgId(), |
---|
| 138 | + finishActivity, ex); |
---|
| 139 | + } |
---|
125 | 140 | } |
---|
old mode 100755new mode 100644.. | .. |
---|
745 | 745 | // We need to convert it to int manually. |
---|
746 | 746 | SettingsManager settingsManager = mActivity.getSettingsManager(); |
---|
747 | 747 | String videoQualityKey = isCameraFrontFacing() ? Keys.KEY_VIDEO_QUALITY_FRONT |
---|
748 | | - : Keys.KEY_VIDEO_QUALITY_BACK; |
---|
| 748 | + : isCameraBackFacing() ? Keys.KEY_VIDEO_QUALITY_BACK : Keys.KEY_VIDEO_QUALITY_EXTERNAL; |
---|
749 | 749 | String videoQuality = settingsManager |
---|
750 | 750 | .getString(SettingsManager.SCOPE_GLOBAL, videoQualityKey); |
---|
751 | 751 | int quality = SettingsUtil.getVideoQuality(videoQuality, mCameraId); |
---|
.. | .. |
---|
1396 | 1396 | mMediaRecorder.start(); // Recording is now started |
---|
1397 | 1397 | } catch (RuntimeException e) { |
---|
1398 | 1398 | Log.e(TAG, "Could not start media recorder. ", e); |
---|
1399 | | - mAppController.getFatalErrorHandler().onGenericCameraAccessFailure(); |
---|
| 1399 | + mAppController.getFatalErrorHandler().onRecordingFailure(); |
---|
1400 | 1400 | releaseMediaRecorder(); |
---|
1401 | 1401 | // If start fails, frameworks will not lock the camera for us. |
---|
1402 | 1402 | mCameraDevice.lock(); |
---|
old mode 100755new mode 100644.. | .. |
---|
203 | 203 | imageHeight, |
---|
204 | 204 | img.proxy.getFormat(), safeCrop); |
---|
205 | 205 | |
---|
206 | | - if(requiresCropOperation(img.proxy, safeCrop)) { |
---|
207 | | - // Crop the image |
---|
208 | | - resultImage = new TaskImage( |
---|
209 | | - exifDerivedRotation, |
---|
210 | | - safeCrop.width(), |
---|
211 | | - safeCrop.height(), |
---|
212 | | - img.proxy.getFormat(), null); |
---|
| 206 | + //if(requiresCropOperation(img.proxy, safeCrop)) { |
---|
| 207 | + // // Crop the image |
---|
| 208 | + // resultImage = new TaskImage( |
---|
| 209 | + // exifDerivedRotation, |
---|
| 210 | + // safeCrop.width(), |
---|
| 211 | + // safeCrop.height(), |
---|
| 212 | + // img.proxy.getFormat(), null); |
---|
213 | 213 | |
---|
214 | | - byte[] croppedResult = decompressCropAndRecompressJpegData( |
---|
215 | | - compressedData.array(), safeCrop, |
---|
216 | | - getJpegCompressionQuality()); |
---|
| 214 | + // byte[] croppedResult = decompressCropAndRecompressJpegData( |
---|
| 215 | + // compressedData.array(), safeCrop, |
---|
| 216 | + // getJpegCompressionQuality()); |
---|
217 | 217 | |
---|
218 | | - compressedData = ByteBuffer.allocate(croppedResult.length); |
---|
219 | | - compressedData.put(ByteBuffer.wrap(croppedResult)); |
---|
220 | | - compressedData.rewind(); |
---|
221 | | - } else { |
---|
222 | | - // Pass-though the JPEG data |
---|
| 218 | + // compressedData = ByteBuffer.allocate(croppedResult.length); |
---|
| 219 | + // compressedData.put(ByteBuffer.wrap(croppedResult)); |
---|
| 220 | + // compressedData.rewind(); |
---|
| 221 | + //} else { |
---|
| 222 | + // // Pass-though the JPEG data |
---|
223 | 223 | resultImage = inputImage; |
---|
224 | | - } |
---|
| 224 | + //} |
---|
225 | 225 | } finally { |
---|
226 | 226 | // Release the image now that you have a usable copy in |
---|
227 | 227 | // local memory |
---|
old mode 100755new mode 100644.. | .. |
---|
203 | 203 | loadSizes(); |
---|
204 | 204 | |
---|
205 | 205 | // Send loaded sizes to additional preferences. |
---|
206 | | - CameraSettingsActivityHelper.onSizesLoaded(this, mPictureSizes.backCameraSizes, |
---|
207 | | - new ListPreferenceFiller() { |
---|
208 | | - @Override |
---|
209 | | - public void fill(List<Size> sizes, ListPreference preference) { |
---|
210 | | - setEntriesForSelection(sizes, preference); |
---|
211 | | - } |
---|
212 | | - }); |
---|
| 206 | + if (!mPictureSizes.backCameraSizes.isEmpty()) { |
---|
| 207 | + CameraSettingsActivityHelper.onSizesLoaded(this, mPictureSizes.backCameraSizes, |
---|
| 208 | + new ListPreferenceFiller() { |
---|
| 209 | + @Override |
---|
| 210 | + public void fill(List<Size> sizes, ListPreference preference) { |
---|
| 211 | + setEntriesForSelection(sizes, preference); |
---|
| 212 | + } |
---|
| 213 | + }); |
---|
| 214 | + } else if (!mPictureSizes.frontCameraSizes.isEmpty()) { |
---|
| 215 | + CameraSettingsActivityHelper.onSizesLoaded(this, mPictureSizes.frontCameraSizes, |
---|
| 216 | + new ListPreferenceFiller() { |
---|
| 217 | + @Override |
---|
| 218 | + public void fill(List<Size> sizes, ListPreference preference) { |
---|
| 219 | + setEntriesForSelection(sizes, preference); |
---|
| 220 | + } |
---|
| 221 | + }); |
---|
| 222 | + } else { |
---|
| 223 | + CameraSettingsActivityHelper.onSizesLoaded(this, mPictureSizes.externalCameraSizes, |
---|
| 224 | + new ListPreferenceFiller() { |
---|
| 225 | + @Override |
---|
| 226 | + public void fill(List<Size> sizes, ListPreference preference) { |
---|
| 227 | + setEntriesForSelection(sizes, preference); |
---|
| 228 | + } |
---|
| 229 | + }); |
---|
| 230 | + } |
---|
213 | 231 | |
---|
214 | 232 | // Make sure to hide settings for cameras that don't exist on this |
---|
215 | 233 | // device. |
---|
.. | .. |
---|
309 | 327 | recursiveDelete(resolutions, |
---|
310 | 328 | findPreference(Keys.KEY_VIDEO_QUALITY_FRONT)); |
---|
311 | 329 | } |
---|
| 330 | + if (mPictureSizes.externalCameraSizes.isEmpty()) { |
---|
| 331 | + recursiveDelete(resolutions, |
---|
| 332 | + findPreference(Keys.KEY_PICTURE_SIZE_EXTERNAL)); |
---|
| 333 | + recursiveDelete(resolutions, |
---|
| 334 | + findPreference(Keys.KEY_VIDEO_QUALITY_EXTERNAL)); |
---|
| 335 | + } |
---|
312 | 336 | } |
---|
313 | 337 | |
---|
314 | 338 | /** |
---|
.. | .. |
---|
382 | 406 | setEntriesForSelection(mPictureSizes.backCameraSizes, listPreference); |
---|
383 | 407 | } else if (listPreference.getKey().equals(Keys.KEY_PICTURE_SIZE_FRONT)) { |
---|
384 | 408 | setEntriesForSelection(mPictureSizes.frontCameraSizes, listPreference); |
---|
| 409 | + } else if (listPreference.getKey().equals(Keys.KEY_PICTURE_SIZE_EXTERNAL)) { |
---|
| 410 | + setEntriesForSelection(mPictureSizes.externalCameraSizes, listPreference); |
---|
385 | 411 | } else if (listPreference.getKey().equals(Keys.KEY_VIDEO_QUALITY_BACK)) { |
---|
386 | 412 | setEntriesForSelection(mPictureSizes.videoQualitiesBack.orNull(), listPreference); |
---|
387 | 413 | } else if (listPreference.getKey().equals(Keys.KEY_VIDEO_QUALITY_FRONT)) { |
---|
388 | 414 | setEntriesForSelection(mPictureSizes.videoQualitiesFront.orNull(), listPreference); |
---|
| 415 | + } else if (listPreference.getKey().equals(Keys.KEY_VIDEO_QUALITY_EXTERNAL)) { |
---|
| 416 | + setEntriesForSelection(mPictureSizes.videoQualitiesExternal.orNull(), listPreference); |
---|
389 | 417 | } |
---|
390 | 418 | } |
---|
391 | 419 | |
---|
.. | .. |
---|
405 | 433 | } else if (listPreference.getKey().equals(Keys.KEY_PICTURE_SIZE_FRONT)) { |
---|
406 | 434 | setSummaryForSelection(mPictureSizes.frontCameraSizes, |
---|
407 | 435 | listPreference); |
---|
| 436 | + } else if (listPreference.getKey().equals(Keys.KEY_PICTURE_SIZE_EXTERNAL)) { |
---|
| 437 | + setSummaryForSelection(mPictureSizes.externalCameraSizes, |
---|
| 438 | + listPreference); |
---|
408 | 439 | } else if (listPreference.getKey().equals(Keys.KEY_VIDEO_QUALITY_BACK)) { |
---|
409 | 440 | setSummaryForSelection(mPictureSizes.videoQualitiesBack.orNull(), listPreference); |
---|
410 | 441 | } else if (listPreference.getKey().equals(Keys.KEY_VIDEO_QUALITY_FRONT)) { |
---|
411 | 442 | setSummaryForSelection(mPictureSizes.videoQualitiesFront.orNull(), listPreference); |
---|
| 443 | + } else if (listPreference.getKey().equals(Keys.KEY_VIDEO_QUALITY_EXTERNAL)) { |
---|
| 444 | + setSummaryForSelection(mPictureSizes.videoQualitiesExternal.orNull(), listPreference); |
---|
412 | 445 | } else { |
---|
413 | 446 | listPreference.setSummary(listPreference.getEntry()); |
---|
414 | 447 | } |
---|
old mode 100755new mode 100644.. | .. |
---|
130 | 130 | context.getString(R.string.pref_camera_focusmode_default), |
---|
131 | 131 | context.getResources().getStringArray(R.array.pref_camera_focusmode_entryvalues)); |
---|
132 | 132 | |
---|
133 | | - String videoQualityBackDefaultValue = context.getString(R.string.pref_video_quality_large); |
---|
| 133 | + String videoQualityBackDefaultValue = context.getString(R.string.pref_video_quality_small); |
---|
134 | 134 | // TODO: We tweaked the default setting based on model string which is not ideal. Detecting |
---|
135 | 135 | // CamcorderProfile capability is a better way to get this job done. However, |
---|
136 | 136 | // |CamcorderProfile.hasProfile| needs camera id info. We need a way to provide camera id to |
---|
.. | .. |
---|
149 | 149 | } |
---|
150 | 150 | |
---|
151 | 151 | settingsManager.setDefaults(KEY_VIDEO_QUALITY_FRONT, |
---|
152 | | - context.getString(R.string.pref_video_quality_large), |
---|
| 152 | + context.getString(R.string.pref_video_quality_small), |
---|
153 | 153 | context.getResources().getStringArray(R.array.pref_video_quality_entryvalues)); |
---|
154 | 154 | if (!settingsManager.isSet(SettingsManager.SCOPE_GLOBAL, Keys.KEY_VIDEO_QUALITY_FRONT)) { |
---|
155 | 155 | settingsManager.setToDefault(SettingsManager.SCOPE_GLOBAL, |
---|
156 | 156 | Keys.KEY_VIDEO_QUALITY_FRONT); |
---|
157 | 157 | } |
---|
158 | 158 | |
---|
| 159 | + settingsManager.setDefaults(KEY_VIDEO_QUALITY_EXTERNAL, |
---|
| 160 | + context.getString(R.string.pref_video_quality_small), |
---|
| 161 | + context.getResources().getStringArray(R.array.pref_video_quality_entryvalues)); |
---|
| 162 | + if (!settingsManager.isSet(SettingsManager.SCOPE_GLOBAL, Keys.KEY_VIDEO_QUALITY_EXTERNAL)) { |
---|
| 163 | + settingsManager.setToDefault(SettingsManager.SCOPE_GLOBAL, |
---|
| 164 | + Keys.KEY_VIDEO_QUALITY_EXTERNAL); |
---|
| 165 | + } |
---|
| 166 | + |
---|
159 | 167 | settingsManager.setDefaults(KEY_JPEG_QUALITY, |
---|
160 | 168 | context.getString(R.string.pref_camera_jpeg_quality_normal), |
---|
161 | 169 | context.getResources().getStringArray( |
---|
old mode 100755new mode 100644.. | .. |
---|
49 | 49 | public static class PictureSizes { |
---|
50 | 50 | public final List<Size> backCameraSizes; |
---|
51 | 51 | public final List<Size> frontCameraSizes; |
---|
| 52 | + public final List<Size> externalCameraSizes; |
---|
52 | 53 | public final Optional<SelectedVideoQualities> videoQualitiesBack; |
---|
53 | 54 | public final Optional<SelectedVideoQualities> videoQualitiesFront; |
---|
54 | | - |
---|
| 55 | + public final Optional<SelectedVideoQualities> videoQualitiesExternal; |
---|
55 | 56 | PictureSizes(List<Size> backCameraSizes, |
---|
56 | 57 | List<Size> frontCameraSizes, |
---|
| 58 | + List<Size> externalCameraSizes, |
---|
57 | 59 | Optional<SelectedVideoQualities> videoQualitiesBack, |
---|
58 | | - Optional<SelectedVideoQualities> videoQualitiesFront) { |
---|
| 60 | + Optional<SelectedVideoQualities> videoQualitiesFront, |
---|
| 61 | + Optional<SelectedVideoQualities> videoQualitiesExternal) { |
---|
59 | 62 | this.backCameraSizes = backCameraSizes; |
---|
60 | 63 | this.frontCameraSizes = frontCameraSizes; |
---|
| 64 | + this.externalCameraSizes = externalCameraSizes; |
---|
61 | 65 | this.videoQualitiesBack = videoQualitiesBack; |
---|
62 | 66 | this.videoQualitiesFront = videoQualitiesFront; |
---|
| 67 | + this.videoQualitiesExternal = videoQualitiesExternal; |
---|
63 | 68 | } |
---|
64 | 69 | } |
---|
65 | 70 | |
---|
.. | .. |
---|
111 | 116 | * We then calculate the resolutions that should be available and in the end |
---|
112 | 117 | * filter it in case a resolution is on the blacklist for this device. |
---|
113 | 118 | */ |
---|
| 119 | + |
---|
114 | 120 | public PictureSizes computePictureSizes() { |
---|
115 | 121 | List<Size> backCameraSizes = computeSizesForCamera(SettingsUtil.CAMERA_FACING_BACK); |
---|
116 | 122 | List<Size> frontCameraSizes = computeSizesForCamera(SettingsUtil.CAMERA_FACING_FRONT); |
---|
| 123 | + List<Size> externalCameraSizes = computeSizesForCamera(SettingsUtil.CAMERA_FACING_EXTERNAL); |
---|
117 | 124 | Optional<SelectedVideoQualities> videoQualitiesBack = |
---|
118 | | - computeQualitiesForCamera(SettingsUtil.CAMERA_FACING_BACK); |
---|
| 125 | + computeQualitiesForCamera(SettingsUtil.CAMERA_FACING_BACK); |
---|
119 | 126 | Optional<SelectedVideoQualities> videoQualitiesFront = |
---|
120 | | - computeQualitiesForCamera(SettingsUtil.CAMERA_FACING_FRONT); |
---|
121 | | - return new PictureSizes(backCameraSizes, frontCameraSizes, videoQualitiesBack, |
---|
122 | | - videoQualitiesFront); |
---|
| 127 | + computeQualitiesForCamera(SettingsUtil.CAMERA_FACING_FRONT); |
---|
| 128 | + Optional<SelectedVideoQualities> videoQualitiesExternal = |
---|
| 129 | + computeQualitiesForCamera(SettingsUtil.CAMERA_FACING_EXTERNAL); |
---|
| 130 | + return new PictureSizes(backCameraSizes, frontCameraSizes, externalCameraSizes, |
---|
| 131 | + videoQualitiesBack, |
---|
| 132 | + videoQualitiesFront, |
---|
| 133 | + videoQualitiesExternal); |
---|
123 | 134 | } |
---|
124 | 135 | |
---|
| 136 | + |
---|
125 | 137 | private List<Size> computeSizesForCamera(CameraDeviceSelector facingSelector) { |
---|
126 | 138 | List<Size> sizes; |
---|
127 | 139 | int cameraId = SettingsUtil.getCameraId(mCameraDeviceInfo, facingSelector); |
---|
old mode 100755new mode 100644.. | .. |
---|
144 | 144 | pictureSize.width() > 0 && pictureSize.height() > 0; |
---|
145 | 145 | |
---|
146 | 146 | if (!isPictureSizeSettingSet || isPictureSizeBlacklisted || !isPictureSizeFromSettingsValid) { |
---|
147 | | - final Rational aspectRatio = ResolutionUtil.ASPECT_RATIO_4x3; |
---|
148 | 147 | |
---|
149 | 148 | OneCameraCharacteristics cameraCharacteristics = |
---|
150 | 149 | mOneCameraManager.getOneCameraCharacteristics(cameraId); |
---|
.. | .. |
---|
153 | 152 | ResolutionUtil.filterBlackListedSizes( |
---|
154 | 153 | cameraCharacteristics.getSupportedPictureSizes(ImageFormat.JPEG), |
---|
155 | 154 | blacklist); |
---|
156 | | - final Size fallbackPictureSize = |
---|
157 | | - ResolutionUtil.getLargestPictureSize(aspectRatio, supportedPictureSizes); |
---|
| 155 | + for (Size size: supportedPictureSizes) { |
---|
| 156 | + Log.v(TAG, "supportedPictureSizes size w = " + size.getWidth() +" h = " + size.getHeight()); |
---|
| 157 | + } |
---|
| 158 | + |
---|
| 159 | + //provide 4x3 and 16x9 selections, compare them and choose larger one. |
---|
| 160 | + //The chosen size must achieve 16bit aligned requirement. |
---|
| 161 | + Size fallbackPictureSize; |
---|
| 162 | + Size LargestPictureSize_4x3 = |
---|
| 163 | + ResolutionUtil.getLargestPictureSize(ResolutionUtil.ASPECT_RATIO_4x3, |
---|
| 164 | + supportedPictureSizes); |
---|
| 165 | + Size LargestPictureSize_16x9 = |
---|
| 166 | + ResolutionUtil.getLargestPictureSize(ResolutionUtil.ASPECT_RATIO_16x9, |
---|
| 167 | + supportedPictureSizes); |
---|
| 168 | + if (LargestPictureSize_4x3.getWidth() > LargestPictureSize_16x9.getWidth()) { |
---|
| 169 | + fallbackPictureSize = LargestPictureSize_4x3; |
---|
| 170 | + } else { |
---|
| 171 | + fallbackPictureSize = LargestPictureSize_16x9; |
---|
| 172 | + } |
---|
| 173 | + |
---|
158 | 174 | mSettingsManager.set( |
---|
159 | 175 | SettingsManager.SCOPE_GLOBAL, |
---|
160 | 176 | pictureSizeSettingKey, |
---|
old mode 100755new mode 100644.. | .. |
---|
359 | 359 | return Math.abs(ar1.toDouble() - ar2.toDouble()) < ASPECT_RATIO_TOLERANCE; |
---|
360 | 360 | } |
---|
361 | 361 | |
---|
| 362 | + public static boolean is16BitAligned(Size size) { |
---|
| 363 | + int width = size.getWidth(); |
---|
| 364 | + int height = size.getHeight(); |
---|
| 365 | + if (((width & 15) == 0) && ((height & 15) == 0)) { |
---|
| 366 | + return true; |
---|
| 367 | + } else { |
---|
| 368 | + return false; |
---|
| 369 | + } |
---|
| 370 | + } |
---|
| 371 | + |
---|
362 | 372 | /** |
---|
363 | 373 | * Selects the maximal resolution for the given desired aspect ratio from all available |
---|
364 | 374 | * resolutions. If no resolution exists for the desired aspect ratio, return a resolution |
---|
.. | .. |
---|
392 | 402 | for (Size size : sizes) { |
---|
393 | 403 | Rational aspectRatio = getAspectRatio(size); |
---|
394 | 404 | // Skip if the aspect ratio is not desired. |
---|
395 | | - if (!hasSameAspectRatio(aspectRatio, desiredAspectRatio)) { |
---|
| 405 | + if (!hasSameAspectRatio(aspectRatio, desiredAspectRatio) || |
---|
| 406 | + !is16BitAligned(size)) { |
---|
396 | 407 | continue; |
---|
397 | 408 | } |
---|
| 409 | + |
---|
398 | 410 | int pixelNum = size.getWidth() * size.getHeight(); |
---|
399 | 411 | if (pixelNum > maxPixelNumWithAspect) { |
---|
400 | 412 | maxPixelNumWithAspect = pixelNum; |
---|
old mode 100755new mode 100644.. | .. |
---|
513 | 513 | public boolean useCamera(CameraDeviceInfo.Characteristics info) { |
---|
514 | 514 | return info.isFacingFront(); |
---|
515 | 515 | }}; |
---|
| 516 | + public static final CameraDeviceSelector CAMERA_FACING_EXTERNAL = new CameraDeviceSelector() { |
---|
| 517 | + @Override |
---|
| 518 | + public boolean useCamera(CameraDeviceInfo.Characteristics info) { |
---|
| 519 | + return info.isFacingExternal(); |
---|
| 520 | + }}; |
---|
516 | 521 | } |
---|