Merge "RecoverySystemService: Dump exception stack on IOExceptions." into nyc-dev
am: 450c34c
* commit '450c34c7b2410d7aa8b0e5787399eee0a758fe99':
RecoverySystemService: Dump exception stack on IOExceptions.
This commit is contained in:
@@ -79,7 +79,7 @@ public final class RecoverySystemService extends SystemService {
|
|||||||
uncryptFile.write(filename + "\n");
|
uncryptFile.write(filename + "\n");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Slog.e(TAG, "IOException when writing \"" + RecoverySystem.UNCRYPT_PACKAGE_FILE +
|
Slog.e(TAG, "IOException when writing \"" + RecoverySystem.UNCRYPT_PACKAGE_FILE +
|
||||||
"\": " + e.getMessage());
|
"\": ", e);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,8 +94,11 @@ public final class RecoverySystemService extends SystemService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Read the status from the socket.
|
// Read the status from the socket.
|
||||||
try (DataInputStream dis = new DataInputStream(socket.getInputStream());
|
DataInputStream dis = null;
|
||||||
DataOutputStream dos = new DataOutputStream(socket.getOutputStream())) {
|
DataOutputStream dos = null;
|
||||||
|
try {
|
||||||
|
dis = new DataInputStream(socket.getInputStream());
|
||||||
|
dos = new DataOutputStream(socket.getOutputStream());
|
||||||
int lastStatus = Integer.MIN_VALUE;
|
int lastStatus = Integer.MIN_VALUE;
|
||||||
while (true) {
|
while (true) {
|
||||||
int status = dis.readInt();
|
int status = dis.readInt();
|
||||||
@@ -111,7 +114,7 @@ public final class RecoverySystemService extends SystemService {
|
|||||||
if (listener != null) {
|
if (listener != null) {
|
||||||
try {
|
try {
|
||||||
listener.onProgress(status);
|
listener.onProgress(status);
|
||||||
} catch (RemoteException unused) {
|
} catch (RemoteException ignored) {
|
||||||
Slog.w(TAG, "RemoteException when posting progress");
|
Slog.w(TAG, "RemoteException when posting progress");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -121,7 +124,6 @@ public final class RecoverySystemService extends SystemService {
|
|||||||
// waits for the ack so the socket won't be
|
// waits for the ack so the socket won't be
|
||||||
// destroyed before we receive the code.
|
// destroyed before we receive the code.
|
||||||
dos.writeInt(0);
|
dos.writeInt(0);
|
||||||
dos.flush();
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -131,14 +133,15 @@ public final class RecoverySystemService extends SystemService {
|
|||||||
// for the ack so the socket won't be destroyed before
|
// for the ack so the socket won't be destroyed before
|
||||||
// we receive the code.
|
// we receive the code.
|
||||||
dos.writeInt(0);
|
dos.writeInt(0);
|
||||||
dos.flush();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Slog.e(TAG, "IOException when reading status: " + e);
|
Slog.e(TAG, "IOException when reading status: ", e);
|
||||||
return false;
|
return false;
|
||||||
} finally {
|
} finally {
|
||||||
|
IoUtils.closeQuietly(dis);
|
||||||
|
IoUtils.closeQuietly(dos);
|
||||||
IoUtils.closeQuietly(socket);
|
IoUtils.closeQuietly(socket);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -169,11 +172,11 @@ public final class RecoverySystemService extends SystemService {
|
|||||||
LocalSocketAddress.Namespace.RESERVED));
|
LocalSocketAddress.Namespace.RESERVED));
|
||||||
done = true;
|
done = true;
|
||||||
break;
|
break;
|
||||||
} catch (IOException unused) {
|
} catch (IOException ignored) {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(1000);
|
Thread.sleep(1000);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
Slog.w(TAG, "Interrupted: " + e);
|
Slog.w(TAG, "Interrupted: ", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -200,8 +203,12 @@ public final class RecoverySystemService extends SystemService {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
try (DataInputStream dis = new DataInputStream(socket.getInputStream());
|
DataInputStream dis = null;
|
||||||
DataOutputStream dos = new DataOutputStream(socket.getOutputStream())) {
|
DataOutputStream dos = null;
|
||||||
|
try {
|
||||||
|
dis = new DataInputStream(socket.getInputStream());
|
||||||
|
dos = new DataOutputStream(socket.getOutputStream());
|
||||||
|
|
||||||
// Send the BCB commands if it's to setup BCB.
|
// Send the BCB commands if it's to setup BCB.
|
||||||
if (isSetup) {
|
if (isSetup) {
|
||||||
dos.writeInt(command.length());
|
dos.writeInt(command.length());
|
||||||
@@ -215,7 +222,6 @@ public final class RecoverySystemService extends SystemService {
|
|||||||
// Ack receipt of the status code. uncrypt waits for the ack so
|
// Ack receipt of the status code. uncrypt waits for the ack so
|
||||||
// the socket won't be destroyed before we receive the code.
|
// the socket won't be destroyed before we receive the code.
|
||||||
dos.writeInt(0);
|
dos.writeInt(0);
|
||||||
dos.flush();
|
|
||||||
|
|
||||||
if (status == 100) {
|
if (status == 100) {
|
||||||
Slog.i(TAG, "uncrypt " + (isSetup ? "setup" : "clear") +
|
Slog.i(TAG, "uncrypt " + (isSetup ? "setup" : "clear") +
|
||||||
@@ -226,9 +232,11 @@ public final class RecoverySystemService extends SystemService {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Slog.e(TAG, "IOException when getting output stream: " + e);
|
Slog.e(TAG, "IOException when communicating with uncrypt: ", e);
|
||||||
return false;
|
return false;
|
||||||
} finally {
|
} finally {
|
||||||
|
IoUtils.closeQuietly(dis);
|
||||||
|
IoUtils.closeQuietly(dos);
|
||||||
IoUtils.closeQuietly(socket);
|
IoUtils.closeQuietly(socket);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user