Java Code Examples for android.os.ParcelFileDescriptor#dup()
The following examples show how to use
android.os.ParcelFileDescriptor#dup() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FimiMediaPlayer.java From FimiX8-RE with MIT License | 6 votes |
@TargetApi(13) public void setDataSource(FileDescriptor fd) throws IOException, IllegalArgumentException, IllegalStateException { if (VERSION.SDK_INT < 12) { try { Field f = fd.getClass().getDeclaredField("descriptor"); f.setAccessible(true); _setDataSourceFd(f.getInt(fd)); return; } catch (NoSuchFieldException e) { throw new RuntimeException(e); } catch (IllegalAccessException e2) { throw new RuntimeException(e2); } } ParcelFileDescriptor pfd = ParcelFileDescriptor.dup(fd); try { _setDataSourceFd(pfd.getFd()); } finally { pfd.close(); } }
Example 2
Source File: FimiMediaPlayer.java From FimiX8-RE with MIT License | 6 votes |
@TargetApi(13) public void setDataSource(FileDescriptor fd) throws IOException, IllegalArgumentException, IllegalStateException { if (VERSION.SDK_INT < 12) { try { Field f = fd.getClass().getDeclaredField("descriptor"); f.setAccessible(true); _setDataSourceFd(f.getInt(fd)); return; } catch (NoSuchFieldException e) { throw new RuntimeException(e); } catch (IllegalAccessException e2) { throw new RuntimeException(e2); } } ParcelFileDescriptor pfd = ParcelFileDescriptor.dup(fd); try { _setDataSourceFd(pfd.getFd()); } finally { pfd.close(); } }
Example 3
Source File: PackageInstallerSession.java From container with GNU General Public License v3.0 | 6 votes |
private ParcelFileDescriptor openReadInternal(String name) throws IOException { assertPreparedAndNotSealed("openRead"); try { if (!FileUtils.isValidExtFilename(name)) { throw new IllegalArgumentException("Invalid name: " + name); } final File target = new File(resolveStageDir(), name); final FileDescriptor targetFd = Os.open(target.getAbsolutePath(), O_RDONLY, 0); return ParcelFileDescriptor.dup(targetFd); } catch (ErrnoException e) { throw new IOException(e); } }
Example 4
Source File: ActivityThread.java From AndroidComponentPlugin with Apache License 2.0 | 5 votes |
public void dumpService(FileDescriptor fd, IBinder servicetoken, String[] args) { DumpComponentInfo data = new DumpComponentInfo(); try { data.fd = ParcelFileDescriptor.dup(fd); data.token = servicetoken; data.args = args; queueOrSendMessage(H.DUMP_SERVICE, data); } catch (IOException e) { Slog.w(TAG, "dumpService failed", e); } }
Example 5
Source File: ActivityThread.java From AndroidComponentPlugin with Apache License 2.0 | 5 votes |
public void dumpActivity(FileDescriptor fd, IBinder activitytoken, String prefix, String[] args) { DumpComponentInfo data = new DumpComponentInfo(); try { data.fd = ParcelFileDescriptor.dup(fd); data.token = activitytoken; data.prefix = prefix; data.args = args; queueOrSendMessage(H.DUMP_ACTIVITY, data); } catch (IOException e) { Slog.w(TAG, "dumpActivity failed", e); } }
Example 6
Source File: ActivityThread.java From AndroidComponentPlugin with Apache License 2.0 | 5 votes |
public void dumpProvider(FileDescriptor fd, IBinder providertoken, String[] args) { DumpComponentInfo data = new DumpComponentInfo(); try { data.fd = ParcelFileDescriptor.dup(fd); data.token = providertoken; data.args = args; queueOrSendMessage(H.DUMP_PROVIDER, data); } catch (IOException e) { Slog.w(TAG, "dumpProvider failed", e); } }
Example 7
Source File: ActivityThread.java From AndroidComponentPlugin with Apache License 2.0 | 5 votes |
public void dumpService(FileDescriptor fd, IBinder servicetoken, String[] args) { DumpComponentInfo data = new DumpComponentInfo(); try { data.fd = ParcelFileDescriptor.dup(fd); data.token = servicetoken; data.args = args; queueOrSendMessage(H.DUMP_SERVICE, data); } catch (IOException e) { Slog.w(TAG, "dumpService failed", e); } }
Example 8
Source File: ActivityThread.java From AndroidComponentPlugin with Apache License 2.0 | 5 votes |
public void dumpActivity(FileDescriptor fd, IBinder activitytoken, String prefix, String[] args) { DumpComponentInfo data = new DumpComponentInfo(); try { data.fd = ParcelFileDescriptor.dup(fd); data.token = activitytoken; data.prefix = prefix; data.args = args; queueOrSendMessage(H.DUMP_ACTIVITY, data); } catch (IOException e) { Slog.w(TAG, "dumpActivity failed", e); } }
Example 9
Source File: PackageManagerShellCommand.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
@Override public void onSuccess(ParcelFileDescriptor profileReadFd) { mSuccess = true; try { // We need to dup the descriptor. We are in the same process as system server // and we will be receiving the same object (which will be closed on the // server side). mProfileReadFd = profileReadFd.dup(); } catch (IOException e) { e.printStackTrace(); } mDoneSignal.countDown(); }
Example 10
Source File: IpSecUdpEncapResponse.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
public IpSecUdpEncapResponse(int inStatus, int inResourceId, int inPort, FileDescriptor inFd) throws IOException { if (inStatus == IpSecManager.Status.OK && inFd == null) { throw new IllegalArgumentException("Valid status implies FD must be non-null"); } status = inStatus; resourceId = inResourceId; port = inPort; fileDescriptor = (status == IpSecManager.Status.OK) ? ParcelFileDescriptor.dup(inFd) : null; }
Example 11
Source File: ParcelFileDescriptorUtils.java From FontProvider with MIT License | 5 votes |
public static ParcelFileDescriptor dupSilently(FileDescriptor fd) { try { return ParcelFileDescriptor.dup(fd); } catch (IOException e) { e.printStackTrace(); return null; } }
Example 12
Source File: PackageInstallerSession.java From container with GNU General Public License v3.0 | 5 votes |
private ParcelFileDescriptor openWriteInternal(String name, long offsetBytes, long lengthBytes) throws IOException { // Quick sanity check of state, and allocate a pipe for ourselves. We // then do heavy disk allocation outside the lock, but this open pipe // will block any attempted install transitions. final FileBridge bridge; synchronized (mLock) { assertPreparedAndNotSealed("openWrite"); bridge = new FileBridge(); mBridges.add(bridge); } try { final File target = new File(resolveStageDir(), name); // TODO: this should delegate to DCS so the system process avoids // holding open FDs into containers. final FileDescriptor targetFd = Os.open(target.getAbsolutePath(), O_CREAT | O_WRONLY, 0644); // If caller specified a total length, allocate it for them. Free up // cache space to grow, if needed. if (lengthBytes > 0) { Os.posix_fallocate(targetFd, 0, lengthBytes); } if (offsetBytes > 0) { Os.lseek(targetFd, offsetBytes, OsConstants.SEEK_SET); } bridge.setTargetFile(targetFd); bridge.start(); return ParcelFileDescriptor.dup(bridge.getClientSocket()); } catch (ErrnoException e) { throw new IOException(e); } }
Example 13
Source File: ParamsFixer.java From AppOpsX with MIT License | 5 votes |
private static Object marshallParamater(Class type,Object obj) { if (FileDescriptor.class.equals(type) && obj instanceof FileDescriptor) { try { return ParcelFileDescriptor.dup(((FileDescriptor) obj)); } catch (IOException e) { e.printStackTrace(); } } return obj; }