diff options
| -rw-r--r-- | services/companion/java/com/android/server/companion/transport/SecureTransport.java | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/services/companion/java/com/android/server/companion/transport/SecureTransport.java b/services/companion/java/com/android/server/companion/transport/SecureTransport.java index 949f39ae1609..277bd88e21ca 100644 --- a/services/companion/java/com/android/server/companion/transport/SecureTransport.java +++ b/services/companion/java/com/android/server/companion/transport/SecureTransport.java @@ -68,24 +68,10 @@ class SecureTransport extends Transport implements SecureChannel.Callback { } @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; |