Fix crash in TranserPipe.
Sometimes the pipe has been closed when it's thread tries to access E AndroidRuntime: *** FATAL EXCEPTION IN SYSTEM PROCESS: TransferPipe E AndroidRuntime: java.lang.NullPointerException: Attempt to invoke virtual method 'java.io.FileDescriptor android.os.ParcelFileDescriptor.getFileDescriptor()' on a null object reference E AndroidRuntime: at com.android.internal.os.TransferPipe.run(TransferPipe.java:184) E AndroidRuntime: at java.lang.Thread.run(Thread.java:818) Change-Id: I0fcd4a3334b49972903f2cb0edb51323ba3f49e5
This commit is contained in:
committed by
Ramanan Rajeswaran
parent
c68f27625b
commit
5ec679a0fa
@@ -174,15 +174,27 @@ public final class TransferPipe implements Runnable {
|
||||
}
|
||||
|
||||
public void kill() {
|
||||
closeFd(0);
|
||||
closeFd(1);
|
||||
synchronized (this) {
|
||||
closeFd(0);
|
||||
closeFd(1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
final byte[] buffer = new byte[1024];
|
||||
final FileInputStream fis = new FileInputStream(getReadFd().getFileDescriptor());
|
||||
final FileOutputStream fos = new FileOutputStream(mOutFd);
|
||||
final FileInputStream fis;
|
||||
final FileOutputStream fos;
|
||||
|
||||
synchronized (this) {
|
||||
ParcelFileDescriptor readFd = getReadFd();
|
||||
if (readFd == null) {
|
||||
Slog.w(TAG, "Pipe has been closed...");
|
||||
return;
|
||||
}
|
||||
fis = new FileInputStream(readFd.getFileDescriptor());
|
||||
fos = new FileOutputStream(mOutFd);
|
||||
}
|
||||
|
||||
if (DEBUG) Slog.i(TAG, "Ready to read pipe...");
|
||||
byte[] bufferPrefix = null;
|
||||
|
||||
Reference in New Issue
Block a user