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

Commit 98d02a21 authored by Raphael Kim's avatar Raphael Kim
Browse files

[W][CDM] Initialize a transport with extended patch diff if device is WEARABLE_SENSING

Bug: 375493122
Test: WIP
Flag: EXEMPT bugfix
Change-Id: I28de59046785036a8b4a1bc1836ddebe74ced021
parent ab349d6a
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -16,7 +16,9 @@

package com.android.server.companion.transport;

import static android.companion.AssociationRequest.DEVICE_PROFILE_WEARABLE_SENSING;
import static android.companion.CompanionDeviceManager.MESSAGE_REQUEST_PERMISSION_RESTORE;
import static android.companion.CompanionDeviceManager.TRANSPORT_FLAG_EXTEND_PATCH_DIFF;

import static com.android.server.companion.transport.TransportUtils.enforceAssociationCanUseTransportFlags;

@@ -169,7 +171,7 @@ public class CompanionTransportManager {
            }

            // TODO: Implement new API to pass a PSK
            initializeTransport(associationId, fd, null, flags);
            initializeTransport(association, fd, null, flags);

            notifyOnTransportsChanged();
        }
@@ -223,11 +225,12 @@ public class CompanionTransportManager {
        }
    }

    private void initializeTransport(int associationId,
    private void initializeTransport(AssociationInfo association,
                                     ParcelFileDescriptor fd,
                                     byte[] preSharedKey,
                                     int flags) {
        Slog.i(TAG, "Initializing transport");
        int associationId = association.getId();
        Transport transport;
        if (!isSecureTransportEnabled()) {
            // If secure transport is explicitly disabled for testing, use raw transport
@@ -242,6 +245,12 @@ public class CompanionTransportManager {
            // If either device is not Android, then use app-specific pre-shared key
            Slog.d(TAG, "Creating a PSK-authenticated secure channel");
            transport = new SecureTransport(associationId, fd, mContext, preSharedKey, null, 0);
        } else if (DEVICE_PROFILE_WEARABLE_SENSING.equals(association.getDeviceProfile())) {
            // If device is glasses with WEARABLE_SENSING profile, extend the allowed patch
            // difference to 2 years instead of 1.
            Slog.d(TAG, "Creating a secure channel with extended patch difference allowance");
            transport = new SecureTransport(associationId, fd, mContext,
                    TRANSPORT_FLAG_EXTEND_PATCH_DIFF);
        } else {
            // If none of the above applies, then use secure channel with attestation verification
            Slog.d(TAG, "Creating a secure channel");