@@ -277,14 +277,27 @@ public void onReceive(byte[] videoBuffer, int size) {
277277 } else {
278278 if (!product .getModel ().equals (Model .UNKNOWN_AIRCRAFT )) {
279279 mCamera = product .getCamera ();
280- mCamera .setMode (SettingsDefinitions .CameraMode .SHOOT_PHOTO , new CommonCallbacks .CompletionCallback () {
281- @ Override
282- public void onResult (DJIError djiError ) {
283- if (djiError != null ) {
284- showToast ("can't change mode of camera, error:" +djiError .getDescription ());
285- }
280+ if (mCamera != null ) {
281+ if (mCamera .isFlatCameraModeSupported ()) {
282+ mCamera .setFlatMode (SettingsDefinitions .FlatCameraMode .PHOTO_SINGLE , new CommonCallbacks .CompletionCallback () {
283+ @ Override
284+ public void onResult (DJIError djiError ) {
285+ if (djiError !=null ){
286+ showToast ("can't change flat mode of camera, error:" + djiError .getDescription ());
287+ }
288+ }
289+ });
290+ } else {
291+ mCamera .setMode (SettingsDefinitions .CameraMode .SHOOT_PHOTO , new CommonCallbacks .CompletionCallback () {
292+ @ Override
293+ public void onResult (DJIError djiError ) {
294+ if (djiError != null ) {
295+ showToast ("can't change mode of camera, error:" + djiError .getDescription ());
296+ }
297+ }
298+ });
286299 }
287- });
300+ }
288301
289302 //When calibration is needed or the fetch key frame is required by SDK, should use the provideTranscodedVideoFeed
290303 //to receive the transcoded video feed from main camera.
@@ -493,7 +506,11 @@ private void oldSaveYuvDataToJPEG(byte[] yuvFrame, int width, int height){
493506 + DJIVideoStreamDecoder .getInstance ().frameIndex
494507 + ",array length: "
495508 + bytes .length );
496- screenShot (bytes , Environment .getExternalStorageDirectory () + "/DJI_ScreenShot" , width , height );
509+ if (Build .VERSION .SDK_INT > Build .VERSION_CODES .P ) {
510+ screenShot (bytes , getApplicationContext ().getExternalFilesDir ("DJI" ).getPath () + "/DJI_ScreenShot" , width , height );
511+ } else {
512+ screenShot (bytes , Environment .getExternalStorageDirectory () + "/DJI_ScreenShot" , width , height );
513+ }
497514 }
498515
499516 private void newSaveYuvDataToJPEG (byte [] yuvFrame , int width , int height ){
@@ -513,7 +530,12 @@ private void newSaveYuvDataToJPEG(byte[] yuvFrame, int width, int height){
513530 yuvFrame [length + 2 * i ] = u [i ];
514531 yuvFrame [length + 2 * i + 1 ] = v [i ];
515532 }
516- screenShot (yuvFrame ,Environment .getExternalStorageDirectory () + "/DJI_ScreenShot" , width , height );
533+
534+ if (Build .VERSION .SDK_INT > Build .VERSION_CODES .P ) {
535+ screenShot (yuvFrame , getApplicationContext ().getExternalFilesDir ("DJI" ).getPath () + "/DJI_ScreenShot" , width , height );
536+ } else {
537+ screenShot (yuvFrame , Environment .getExternalStorageDirectory () + "/DJI_ScreenShot" , width , height );
538+ }
517539 }
518540
519541 private void newSaveYuvDataToJPEG420P (byte [] yuvFrame , int width , int height ) {
@@ -533,7 +555,12 @@ private void newSaveYuvDataToJPEG420P(byte[] yuvFrame, int width, int height) {
533555 yuvFrame [length + 2 * i ] = v [i ];
534556 yuvFrame [length + 2 * i + 1 ] = u [i ];
535557 }
536- screenShot (yuvFrame , Environment .getExternalStorageDirectory () + "/DJI_ScreenShot" , width , height );
558+
559+ if (Build .VERSION .SDK_INT > Build .VERSION_CODES .P ) {
560+ screenShot (yuvFrame , getApplicationContext ().getExternalFilesDir ("DJI" ).getPath () + "/DJI_ScreenShot" , width , height );
561+ } else {
562+ screenShot (yuvFrame , Environment .getExternalStorageDirectory () + "/DJI_ScreenShot" , width , height );
563+ }
537564 }
538565
539566 /**
0 commit comments