List of usage examples for android.os ParcelFileDescriptor MODE_READ_WRITE
int MODE_READ_WRITE
To view the source code for android.os ParcelFileDescriptor MODE_READ_WRITE.
Click Source Link
From source file:com.raspi.chatapp.util.storage.file.LocalStorageProvider.java
@Override public ParcelFileDescriptor openDocument(final String documentId, final String mode, final CancellationSignal signal) throws FileNotFoundException { if (LocalStorageProvider.isMissingPermission(getContext())) { return null; }//from w w w . jav a 2s . c o m File file = new File(documentId); final boolean isWrite = (mode.indexOf('w') != -1); if (isWrite) { return ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_WRITE); } else { return ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_ONLY); } }
From source file:org.getlantern.firetweet.provider.FiretweetDataProvider.java
@Override public ParcelFileDescriptor openFile(final Uri uri, final String mode) throws FileNotFoundException { if (uri == null || mode == null) throw new IllegalArgumentException(); final int table_id = getTableId(uri); final String table = getTableNameById(table_id); final int mode_code; if ("r".equals(mode)) { mode_code = ParcelFileDescriptor.MODE_READ_ONLY; } else if ("rw".equals(mode)) { mode_code = ParcelFileDescriptor.MODE_READ_WRITE; } else if ("rwt".equals(mode)) { mode_code = ParcelFileDescriptor.MODE_READ_WRITE | ParcelFileDescriptor.MODE_TRUNCATE; } else//from w ww. j av a 2 s .co m throw new IllegalArgumentException(); if (mode_code == ParcelFileDescriptor.MODE_READ_ONLY) { checkReadPermission(table_id, table, null); } else if ((mode_code & ParcelFileDescriptor.MODE_READ_WRITE) != 0) { checkReadPermission(table_id, table, null); checkWritePermission(table_id, table); } switch (table_id) { case VIRTUAL_TABLE_ID_CACHED_IMAGES: { return getCachedImageFd(uri.getQueryParameter(QUERY_PARAM_URL)); } case VIRTUAL_TABLE_ID_CACHE_FILES: { return getCacheFileFd(uri.getLastPathSegment()); } } return null; }
From source file:com.hippo.content.FileProvider.java
/** * Copied from ContentResolver.java//from w ww.j a v a 2 s. c o m */ private static int modeToMode(String mode) { int modeBits; if ("r".equals(mode)) { modeBits = ParcelFileDescriptor.MODE_READ_ONLY; } else if ("w".equals(mode) || "wt".equals(mode)) { modeBits = ParcelFileDescriptor.MODE_WRITE_ONLY | ParcelFileDescriptor.MODE_CREATE | ParcelFileDescriptor.MODE_TRUNCATE; } else if ("wa".equals(mode)) { modeBits = ParcelFileDescriptor.MODE_WRITE_ONLY | ParcelFileDescriptor.MODE_CREATE | ParcelFileDescriptor.MODE_APPEND; } else if ("rw".equals(mode)) { modeBits = ParcelFileDescriptor.MODE_READ_WRITE | ParcelFileDescriptor.MODE_CREATE; } else if ("rwt".equals(mode)) { modeBits = ParcelFileDescriptor.MODE_READ_WRITE | ParcelFileDescriptor.MODE_CREATE | ParcelFileDescriptor.MODE_TRUNCATE; } else { throw new IllegalArgumentException("Invalid mode: " + mode); } return modeBits; }
From source file:com.ardnezar.lookapp.PeerConnectionClient.java
private void createPeerConnectionInternal(EglBase.Context renderEGLContext, List<PeerConnection.IceServer> list) { if (factory == null || isError) { Log.e(TAG, "Peerconnection factory is not created"); return;//from w w w.java 2s. co m } Log.d(TAG, "Create peer connection."); // Log.d(TAG, "PCConstraints: " + pcConstraints.toString()); if (videoConstraints != null) { Log.d(TAG, "VideoConstraints: " + videoConstraints.toString()); } queuedRemoteCandidates = new LinkedList<IceCandidate>(); if (videoCallEnabled) { Log.d(TAG, "EGLContext: " + renderEGLContext); factory.setVideoHwAccelerationOptions(renderEGLContext, renderEGLContext); } PeerConnection.RTCConfiguration rtcConfig = null; if (list != null) { rtcConfig = new PeerConnection.RTCConfiguration(list); } else { rtcConfig = new PeerConnection.RTCConfiguration(signalingParameters.iceServers); } // TCP candidates are only useful when connecting to a server that supports // ICE-TCP. rtcConfig.tcpCandidatePolicy = PeerConnection.TcpCandidatePolicy.DISABLED; rtcConfig.bundlePolicy = PeerConnection.BundlePolicy.MAXBUNDLE; rtcConfig.rtcpMuxPolicy = PeerConnection.RtcpMuxPolicy.REQUIRE; // Use ECDSA encryption. rtcConfig.keyType = PeerConnection.KeyType.ECDSA; // peerConnection = factory.createPeerConnection( // rtcConfig, pcConstraints, pcObserver); isInitiator = false; // Set default WebRTC tracing and INFO libjingle logging. // NOTE: this _must_ happen while |factory| is alive! Logging.enableTracing("logcat:", EnumSet.of(Logging.TraceLevel.TRACE_DEFAULT), Logging.Severity.LS_INFO); mediaStream = factory.createLocalMediaStream("ARDAMS"); if (videoCallEnabled) { String cameraDeviceName = CameraEnumerationAndroid.getDeviceName(0); String frontCameraDeviceName = CameraEnumerationAndroid.getNameOfFrontFacingDevice(); if (numberOfCameras > 1 && frontCameraDeviceName != null) { cameraDeviceName = frontCameraDeviceName; } Log.d(TAG, "Opening camera: " + cameraDeviceName); videoCapturer = VideoCapturerAndroid.create(cameraDeviceName, null, peerConnectionParameters.captureToTexture ? renderEGLContext : null); if (videoCapturer == null) { reportError("Failed to open camera"); return; } mediaStream.addTrack(createVideoTrack(videoCapturer)); } mediaStream.addTrack(factory.createAudioTrack(AUDIO_TRACK_ID, factory.createAudioSource(audioConstraints))); peerConnection.addStream(mediaStream); if (peerConnectionParameters.aecDump) { try { aecDumpFileDescriptor = ParcelFileDescriptor.open(new File("/sdcard/Download/audio.aecdump"), ParcelFileDescriptor.MODE_READ_WRITE | ParcelFileDescriptor.MODE_CREATE | ParcelFileDescriptor.MODE_TRUNCATE); factory.startAecDump(aecDumpFileDescriptor.getFd()); } catch (IOException e) { Log.e(TAG, "Can not open aecdump file", e); } } Log.d(TAG, "Peer connection created."); }
From source file:com.almalence.plugins.capture.video.VideoCapturePlugin.java
/** * Appends mp4 audio/video from {@code anotherFileName} to * {@code mainFileName}.//from w w w. j a v a2 s . co m */ public static File append(File[] inputFiles) { try { File targetFile = inputFiles[0]; int[] inputFilesFds = new int[inputFiles.length]; ArrayList<ParcelFileDescriptor> pfdsList = new ArrayList<ParcelFileDescriptor>(); int i = 0; for (File f : inputFiles) { ParcelFileDescriptor pfd = ParcelFileDescriptor.open(f, ParcelFileDescriptor.MODE_READ_WRITE); pfdsList.add(pfd); inputFilesFds[i] = pfd.getFd(); i++; } if (targetFile.exists() && targetFile.length() > 0) { File tmpTargetFile = new File(targetFile.getAbsolutePath() + ".tmp"); ParcelFileDescriptor targetFilePfd = ParcelFileDescriptor.open(tmpTargetFile, ParcelFileDescriptor.MODE_CREATE | ParcelFileDescriptor.MODE_READ_WRITE); Mp4Editor.appendFds(inputFilesFds, targetFilePfd.getFd()); targetFilePfd.close(); for (ParcelFileDescriptor pfd : pfdsList) { pfd.close(); } return tmpTargetFile; } else if (targetFile.createNewFile()) { copyFile(inputFiles[1].getAbsolutePath(), inputFiles[0].getAbsolutePath()); return targetFile; } } catch (IOException e) { e.printStackTrace(); } return null; }