Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ead6dacf authored by Josh Gao's avatar Josh Gao
Browse files

Fix file descriptor ownership.

Previously, we attempt to pass ownership of the fd owned by a
ParcelFileDescriptor to a FileInputStream, which explodes when we try to
close it.

Bug: http://b/156867945
Bug: http://b/159264419
Test: treehugger
Change-Id: I9d5124658beb50f0a08499ed09e652037cb9ae66
(cherry picked from commit 3e29e4a3)
parent 85cf4238
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
package com.android.server.backup.restore;

import android.os.ParcelFileDescriptor;
import android.os.ParcelFileDescriptor.AutoCloseInputStream;

import libcore.io.IoUtils;

import java.io.FileInputStream;
import java.io.InputStream;

class FullRestoreEngineThread implements Runnable {
@@ -19,7 +19,7 @@ class FullRestoreEngineThread implements Runnable {
        // We *do* want this FileInputStream to own the underlying fd, so that
        // when we are finished with it, it closes this end of the pipe in a way
        // that signals its other end.
        mEngineStream = new FileInputStream(engineSocket.getFileDescriptor(), true);
        mEngineStream = new AutoCloseInputStream(engineSocket);
        // Tell it to be sure to leave the agent instance up after finishing
        mMustKillAgent = false;
    }