Search code examples
androidperformancedji-sdk

Calling refreshFileListOfStorageLocation() in the DJI Android SDK takes many seconds to produce a result (mavic


The goal of the program I am writing, is the following:

  • take a a jpg image with the DJI mavic 2 enterprise
  • download the jpg image onto the connected android application

The code does this. The issue is, that the entire process takes over 5, sometimes up to 15 seconds to complete. The main bottleneck is the refreshFileListOfStorageLocation() function.

The code setup is the following:


mMediaManager = DJISampleApplication.getProductInstance().getCamera().getMediaManager();
camera = DJISampleApplication.getProductInstance().getCamera();

camera.startShootPhoto(new CommonCallbacks.CompletionCallback() {
    @Override
    public void onResult(DJIError djiError) {
        mMediaManager.refreshFileListOfStorageLocation(SettingsDefinitions.StorageLocation.INTERNAL_STORAGE, new CommonCallbacks.CompletionCallback() {
        @Override
        public void onResult(DJIError djiError) {
        newPicture();
    });
});


void newPicture() {
mediaFileList = mMediaManager.getInternalStorageFileListSnapshot();
MediaFile lastImage = mediaFileList.get(mediaFileList.size()-1);
lastImage.fetchFileData(destDir, names[0], new DownloadListener<String>() {
    @Override
    public void onSuccess(String s) {
        deleteAllFilesFromDrone();
    return;
    }
}

Like I said, this works; the problem is the time between refreshFileListOfStorageLocation() and it's onResult.

Is there any way to speed this up? I've tried:

  • keeping the number of files on the drones storage at 1 max,
  • making a FileState listener through addUpdateFileListStateListener, though this is only triggered once
  • checking the FileListState and only refreshing, if the state is INCOMPLETE or RESET

none of these helped.


Solution

  • According to my correspondence with DJI Developer Support:

    Unfortunately, the universal answer is that the speed is what it is and there's not anything that can be done to speed up the process other than downloading a preview of the media file or manually taking the SD card out and downloading the media directly onto a computer.

    So it does not seem, as if any further speed improvements through any API tricks are possible.