_processLegacyMtpBuffer = async ({ error, stderr }) => {
  // Error string are used for partial error string matching
  // this will be later used to pick the appropriate error out from the [errorDictionary]
  const errorTpl = {
    noMtp: `no mtp`,
    deviceLocked: `your device may be locked`,
    invalidObjectHandle: `invalid response code InvalidObjectHandle`,
    invalidStorageID: `invalid response code InvalidStorageID`,
    fileNotFound: `could not find`,
    noFilesSelected: `No files selected`,
    invalidPath: `Invalid path`,
    noSuchFiles: `No such file or directory`,
    writePipe: `WritePipe`,
    mtpStorageNotAccessible1: `MTP storage not accessible`,
    mtpStorageNotAccessible2: `error: storage`,
    partialDeletion: `PartialDeletion`,
    noPerm1: `cannot open file`,
  };

  // Error output shown to the user as a snackbar.
  const errorDictionary = {
    noPerm: `Operation not permitted.`,
    noMtp: `No ${DEVICES_LABEL[DEVICE_TYPE.mtp]} or MTP device found.`,
    googleAndroidFileTransferIsActive: `Quit 'Android File Transfer' app (by Google) and Refresh.`,
    deviceLocked: `Unlock your ${
      DEVICES_LABEL[DEVICE_TYPE.mtp]
    } and refresh again`,
    unResponsive: `Your ${
      DEVICES_LABEL[DEVICE_TYPE.mtp]
    } is not responding. Reload or reconnect the device.`,
    mtpStorageNotAccessible: `Your ${
      DEVICES_LABEL[DEVICE_TYPE.mtp]
    } storage is not accessible.`,
    fileNotFound: `File not found! Try again.`,
    partialDeletion: `The path is inaccessible.`,
    common: `Oops.. Your ${
      DEVICES_LABEL[DEVICE_TYPE.mtp]
    } has gone crazy! Try again.`,
  };

  const errorStringified =
    typeof error !== 'undefined' && error !== null ? error.toString() : '';
  const stderrStringified =
    typeof stderr !== 'undefined' && stderr !== null ? stderr.toString() : '';

  if (!errorStringified && !stderrStringified) {
    return {
      error: null,
      throwAlert: false,
      logError: true,
      mtpStatus: true,
    };
  }

  const checkError = (errorTplKey) => {
    return (
      stderrStringified
        .toLowerCase()
        .indexOf(errorTpl[errorTplKey].toLowerCase()) !== -1 ||
      errorStringified
        .toLowerCase()
        .indexOf(errorTpl[errorTplKey].toLowerCase()) !== -1
    );
  };

  const noMtpError = isNoMtpError({ error, stderr, mtpMode: MTP_MODE.legacy });

  if (!noMtpError) {
    log.doLog(
      `MTP buffer o/p logging;${EOL}MTP Mode: ${
        MTP_MODE.legacy
      }${EOL}error: ${errorStringified.trim()}${EOL}stderr: ${stderrStringified.trim()}`,
      'processLegacyMtpBuffer'
    );
  }

  if (
    /* No MTP device found */
    noMtpError
  ) {
    const _isGoogleAndroidFileTransferActive =
      await isGoogleAndroidFileTransferActive();

    if (_isGoogleAndroidFileTransferActive) {
      return {
        error: errorDictionary.googleAndroidFileTransferIsActive,
        throwAlert: true,
        logError: true,
        mtpStatus: false,
        reportError: false,
      };
    }

    return {
      error: errorDictionary.noMtp,
      throwAlert: false,
      logError: false,
      mtpStatus: false,

      reportError: false,
    };
  }

  if (
    /* MTP device may be locked */
    checkError('deviceLocked')
  ) {
    return {
      error: errorDictionary.deviceLocked,
      throwAlert: true,
      logError: true,
      mtpStatus: false,

      reportError: false,
    };
  }

  if (
    /* error: Get: invalid response code InvalidObjectHandle (0x2009) */
    checkError('invalidObjectHandle')
  ) {
    return {
      error: errorDictionary.unResponsive,
      throwAlert: true,
      logError: true,
      mtpStatus: false,

      reportError: true,
    };
  }

  if (
    /* error: Get: invalid response code InvalidStorageID */
    checkError('invalidStorageID')
  ) {
    return {
      error: errorDictionary.unResponsive,
      throwAlert: true,
      logError: true,
      mtpStatus: false,
      reportError: true,
    };
  }

  if (
    /* error: (*interface)->WritePipe(interface, ep->GetRefIndex(), buffer.data(), r): error 0xe00002eb */
    checkError('writePipe')
  ) {
    return {
      error: errorDictionary.unResponsive,
      throwAlert: true,
      logError: true,
      mtpStatus: false,
      reportError: true,
    };
  }

  if (
    /* MTP storage not accessible */
    checkError('mtpStorageNotAccessible1') ||
    checkError('mtpStorageNotAccessible2')
  ) {
    return {
      error: errorDictionary.mtpStorageNotAccessible,
      throwAlert: true,
      logError: true,
      mtpStatus: false,
      reportError: true,
    };
  }

  if (
    /* Path not found */
    checkError('fileNotFound')
  ) {
    return {
      error: sanitizeErrors(stderrStringified || errorStringified),
      throwAlert: true,
      logError: true,
      mtpStatus: true,
      reportError: true,
    };
  }

  if (
    /* No Permission */
    checkError('noPerm1')
  ) {
    return {
      error: errorDictionary.noPerm,
      throwAlert: true,
      logError: true,
      mtpStatus: true,
      reportError: true,
    };
  }

  if (
    /* No such file or directory */
    checkError('noSuchFiles')
  ) {
    return {
      error: errorDictionary.fileNotFound,
      throwAlert: true,
      logError: true,
      mtpStatus: true,
      reportError: true,
    };
  }

  if (
    /* No files selected */
    checkError('noFilesSelected') ||
    checkError('invalidPath')
  ) {
    return {
      error: sanitizeErrors(stderrStringified || errorStringified),
      throwAlert: true,
      logError: true,
      mtpStatus: true,
      reportError: true,
    };
  }

  if (
    /* No files selected */
    checkError('partialDeletion')
  ) {
    return {
      error: errorDictionary.partialDeletion,
      throwAlert: true,
      logError: true,
      mtpStatus: true,
      reportError: true,
    };
  }

  /* common errors */
  return {
    error: errorDictionary.common,
    throwAlert: true,
    logError: true,
    mtpStatus: true,
    reportError: true,
  };
}
Helper function for processLegacyMtpBuffer

@param [error] - error
@param [stderr] variable will hold the kalam ffi errorTypes
@return {Promise<{throwAlert: boolean, logError: boolean, mtpStatus: boolean, reportError: boolean, error: string}|{throwAlert: boolean, logError: boolean, mtpStatus: boolean, reportError: boolean, error: null}>}
@private