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

Commit 3e1ed3f5 authored by Joe Antonetti's avatar Joe Antonetti
Browse files

Mark Task Continuity Messages as Oneway

Messages from `TaskContinuityManager` were getting rejected, since the transport wasn't set up to process them. This change amends the transport to do just that.

Test: Added unit tests
Bug: 400970610
Flag: android.companion.enable_task_continuity
Change-Id: I479cb0994e43ec5b77d2e1eaa3972496b5632ac2
parent a8a75cd7
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -266,7 +266,7 @@ public final class CompanionDeviceManager {
     *
     * @hide
     */
    public static final int MESSAGE_TASK_CONTINUITY = 0x63678884; // ?TSK
    public static final int MESSAGE_ONEWAY_TASK_CONTINUITY = 0x43678884; // +TSK
    /**
     * Message header assigned to the permission restore request.
     *
+2 −2
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@

package com.android.server.companion.datatransfer.continuity;

import static android.companion.CompanionDeviceManager.MESSAGE_TASK_CONTINUITY;
import static android.companion.CompanionDeviceManager.MESSAGE_ONEWAY_TASK_CONTINUITY;

import android.app.ActivityManager;
import android.app.ActivityTaskManager;
@@ -171,7 +171,7 @@ class TaskBroadcaster
                .build();

        mCompanionDeviceManager.sendMessage(
            CompanionDeviceManager.MESSAGE_TASK_CONTINUITY,
            CompanionDeviceManager.MESSAGE_ONEWAY_TASK_CONTINUITY,
            message.toBytes(),
            new int[] {associationId});
    }
+3 −3
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@

package com.android.server.companion.datatransfer.continuity;

import static android.companion.CompanionDeviceManager.MESSAGE_TASK_CONTINUITY;
import static android.companion.CompanionDeviceManager.MESSAGE_ONEWAY_TASK_CONTINUITY;

import android.content.Context;
import android.companion.CompanionDeviceManager;
@@ -65,7 +65,7 @@ class TaskContinuityMessageReceiver {
        mOnTaskContinuityMessageReceivedListener = onTaskContinuityMessageReceivedListener;
        mCompanionDeviceManager.addOnMessageReceivedListener(
            mContext.getMainExecutor(),
            MESSAGE_TASK_CONTINUITY,
            MESSAGE_ONEWAY_TASK_CONTINUITY,
            mOnMessageReceivedListener
        );

@@ -85,7 +85,7 @@ class TaskContinuityMessageReceiver {
        mOnTaskContinuityMessageReceivedListener = null;

        mCompanionDeviceManager.removeOnMessageReceivedListener(
            MESSAGE_TASK_CONTINUITY,
            MESSAGE_ONEWAY_TASK_CONTINUITY,
            mOnMessageReceivedListener);

        mIsListening = false;
+3 −1
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import static android.companion.CompanionDeviceManager.MESSAGE_REQUEST_CONTEXT_S
import static android.companion.CompanionDeviceManager.MESSAGE_REQUEST_PERMISSION_RESTORE;
import static android.companion.CompanionDeviceManager.MESSAGE_REQUEST_PING;
import static android.companion.CompanionDeviceManager.MESSAGE_REQUEST_REMOTE_AUTHENTICATION;
import static android.companion.CompanionDeviceManager.MESSAGE_ONEWAY_TASK_CONTINUITY;

import android.annotation.NonNull;
import android.companion.IOnMessageReceivedListener;
@@ -243,7 +244,8 @@ public abstract class Transport {
        switch (message) {
            case MESSAGE_ONEWAY_PING:
            case MESSAGE_ONEWAY_FROM_WEARABLE:
            case MESSAGE_ONEWAY_TO_WEARABLE: {
            case MESSAGE_ONEWAY_TO_WEARABLE:
            case MESSAGE_ONEWAY_TASK_CONTINUITY: {
                callback(message, data);
                break;
            }
+2 −2
Original line number Diff line number Diff line
@@ -160,7 +160,7 @@ public class TaskBroadcasterTest {
        ArgumentCaptor<byte[]> messageCaptor
            = ArgumentCaptor.forClass(byte[].class);
        verify(mMockCompanionDeviceManagerService, times(1)).sendMessage(
            eq(CompanionDeviceManager.MESSAGE_TASK_CONTINUITY),
            eq(CompanionDeviceManager.MESSAGE_ONEWAY_TASK_CONTINUITY),
            messageCaptor.capture(),
            eq(new int[] {1}));
        TaskContinuityMessage taskContinuityMessage = new TaskContinuityMessage(
@@ -202,7 +202,7 @@ public class TaskBroadcasterTest {
        // Verify sendMessage is called
        ArgumentCaptor<byte[]> messageCaptor = ArgumentCaptor.forClass(byte[].class);
        verify(mMockCompanionDeviceManagerService, times(1)).sendMessage(
                eq(CompanionDeviceManager.MESSAGE_TASK_CONTINUITY),
                eq(CompanionDeviceManager.MESSAGE_ONEWAY_TASK_CONTINUITY),
                messageCaptor.capture(),
                any(int[].class));
        byte[] capturedMessage = messageCaptor.getValue();
Loading