Merge "Shuffle FD ownership? \noideadog"

am: 46331602ae

Change-Id: I30e937d0a28361a8e12e9197ef38b0ca8c3840d7
This commit is contained in:
Jeff Sharkey
2018-08-08 16:14:04 -07:00
committed by android-build-merger

View File

@@ -2418,10 +2418,12 @@ class PackageManagerShellCommand extends ShellCommand {
private int doWriteSplit(int sessionId, String inPath, long sizeBytes, String splitName, private int doWriteSplit(int sessionId, String inPath, long sizeBytes, String splitName,
boolean logSuccess) throws RemoteException { boolean logSuccess) throws RemoteException {
PackageInstaller.Session session = null;
try {
final PrintWriter pw = getOutPrintWriter(); final PrintWriter pw = getOutPrintWriter();
final ParcelFileDescriptor fd; final ParcelFileDescriptor fd;
if (STDIN_PATH.equals(inPath)) { if (STDIN_PATH.equals(inPath)) {
fd = new ParcelFileDescriptor(getInFileDescriptor()); fd = ParcelFileDescriptor.dup(getInFileDescriptor());
} else if (inPath != null) { } else if (inPath != null) {
fd = openFileForSystem(inPath, "r"); fd = openFileForSystem(inPath, "r");
if (fd == null) { if (fd == null) {
@@ -2433,15 +2435,13 @@ class PackageManagerShellCommand extends ShellCommand {
return -1; return -1;
} }
} else { } else {
fd = new ParcelFileDescriptor(getInFileDescriptor()); fd = ParcelFileDescriptor.dup(getInFileDescriptor());
} }
if (sizeBytes <= 0) { if (sizeBytes <= 0) {
getErrPrintWriter().println("Error: must specify a APK size"); getErrPrintWriter().println("Error: must specify a APK size");
return 1; return 1;
} }
PackageInstaller.Session session = null;
try {
session = new PackageInstaller.Session( session = new PackageInstaller.Session(
mInterface.getPackageInstaller().openSession(sessionId)); mInterface.getPackageInstaller().openSession(sessionId));
session.write(splitName, 0, sizeBytes, fd); session.write(splitName, 0, sizeBytes, fd);