Source:
protected Integer doInBackground(Void... voids) { try { OutputStream outputStream; switch (fileAbstraction.scheme) { case EditableFileAbstraction.SCHEME_CONTENT: if(fileAbstraction.uri == null) throw new NullPointerException("Something went really wrong!"); outputStream = contentResolver.openOutputStream(fileAbstraction.uri); break; case EditableFileAbstraction.SCHEME_FILE: Context context = this.context.get(); if(context == null) cancel(true); final HybridFileParcelable hybridFileParcelable = fileAbstraction.hybridFileParcelable; if(hybridFileParcelable == null) throw new NullPointerException("Something went really wrong!"); outputStream = FileUtil.getOutputStream(hybridFileParcelable.getFile(), context); if (ThemedActivity.rootMode && outputStream == null) { try { if (cachedFile != null && cachedFile.exists()){ outputStream = new FileOutputStream(cachedFile); } } catch (FileNotFoundException e) { e.printStackTrace(); outputStream = null; } } break; default: throw new IllegalArgumentException("The scheme for '" + fileAbstraction.scheme + "' cannot be processed!"); } if(outputStream == null) throw new StreamNotFoundException(); outputStream.write(dataToSave.getBytes()); outputStream.close(); if (cachedFile != null && cachedFile.exists()) { RootUtils.cat(cachedFile.getPath(), fileAbstraction.hybridFileParcelable.getPath()); cachedFile.delete(); } } catch (IOException e) { e.printStackTrace(); return EXCEPTION_IO; } catch (StreamNotFoundException e) { e.printStackTrace(); return EXCEPTION_STREAM_NOT_FOUND; } catch (ShellNotRunningException e) { e.printStackTrace(); return EXCEPTION_SHELL_NOT_RUNNING; } return NORMAL; }

Target:
protected Integer doInBackground(Void... voids) { try { OutputStream outputStream; switch (fileAbstraction.scheme) { case EditableFileAbstraction.SCHEME_CONTENT: if(fileAbstraction.uri == null) throw new NullPointerException("Something went really wrong!"); try { outputStream = contentResolver.openOutputStream(fileAbstraction.uri); } catch (RuntimeException e) { throw new StreamNotFoundException(e); } break; case EditableFileAbstraction.SCHEME_FILE: final HybridFileParcelable hybridFileParcelable = fileAbstraction.hybridFileParcelable; if(hybridFileParcelable == null) throw new NullPointerException("Something went really wrong!"); Context context = this.context.get(); if(context == null) { cancel(true); return null; } outputStream = FileUtil.getOutputStream(hybridFileParcelable.getFile(), context); if (ThemedActivity.rootMode && outputStream == null) { try { if (cachedFile != null && cachedFile.exists()){ outputStream = new FileOutputStream(cachedFile); } } catch (FileNotFoundException e) { e.printStackTrace(); outputStream = null; } } break; default: throw new IllegalArgumentException("The scheme for '" + fileAbstraction.scheme + "' cannot be processed!"); } if(outputStream == null) throw new StreamNotFoundException(); outputStream.write(dataToSave.getBytes()); outputStream.close(); if (cachedFile != null && cachedFile.exists()) { RootUtils.cat(cachedFile.getPath(), fileAbstraction.hybridFileParcelable.getPath()); cachedFile.delete(); } } catch (IOException e) { e.printStackTrace(); return EXCEPTION_IO; } catch (StreamNotFoundException e) { e.printStackTrace(); return EXCEPTION_STREAM_NOT_FOUND; } catch (ShellNotRunningException e) { e.printStackTrace(); return EXCEPTION_SHELL_NOT_RUNNING; } return NORMAL; }