Merge "[Secure Channel] Establish secure connection on sendMessage" into udc-dev am: f141590772

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/23128745

Change-Id: I5939aba77cba572607fec77096360f9a054294f3
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Guojing Yuan
2023-05-11 21:21:27 +00:00
committed by Automerger Merge Worker

View File

@@ -67,25 +67,11 @@ class SecureTransport extends Transport implements SecureChannel.Callback {
mShouldProcessRequests = false;
}
@Override
public Future<byte[]> requestForResponse(int message, byte[] data) {
// Check if channel is secured and start securing
if (!mShouldProcessRequests) {
Slog.d(TAG, "Establishing secure connection.");
try {
mSecureChannel.establishSecureConnection();
} catch (Exception e) {
Slog.w(TAG, "Failed to initiate secure channel handshake.", e);
onError(e);
}
}
return super.requestForResponse(message, data);
}
@Override
protected void sendMessage(int message, int sequence, @NonNull byte[] data)
throws IOException {
establishSecureConnection();
if (DEBUG) {
Slog.d(TAG, "Queueing message 0x" + Integer.toHexString(message)
+ " sequence " + sequence + " length " + data.length
@@ -103,6 +89,19 @@ class SecureTransport extends Transport implements SecureChannel.Callback {
}
}
private void establishSecureConnection() {
// Check if channel is secured and start securing
if (!mShouldProcessRequests) {
Slog.d(TAG, "Establishing secure connection.");
try {
mSecureChannel.establishSecureConnection();
} catch (Exception e) {
Slog.w(TAG, "Failed to initiate secure channel handshake.", e);
onError(e);
}
}
}
@Override
public void onSecureConnection() {
mShouldProcessRequests = true;