Loading core/java/android/companion/CompanionDeviceManager.java +6 −0 Original line number Diff line number Diff line Loading @@ -260,6 +260,12 @@ public final class CompanionDeviceManager { * @hide */ public static final int MESSAGE_REQUEST_CONTEXT_SYNC = 0x63678883; // ?CXS /** * Message header assigned to task continuity messages. * * @hide */ public static final int MESSAGE_TASK_CONTINUITY = 0x63678884; // ?TSK /** * Message header assigned to the permission restore request. * Loading core/proto/android/companion/OWNERS +2 −0 Original line number Diff line number Diff line include /core/java/android/companion/OWNERS joeantonetti@google.com jackshira@google.com core/proto/android/companion/task_continuity_message.proto 0 → 100644 +32 −0 Original line number Diff line number Diff line /* * Copyright (C) 2025 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ syntax = "proto3"; package android.companion; option java_multiple_files = true; // Next index: 2 message TaskContinuityMessage { oneof data { ContinuityDeviceConnected device_connected = 1; } } message ContinuityDeviceConnected { int32 currentForegroundTaskId = 1; } services/companion/java/com/android/server/companion/datatransfer/continuity/messages/ContinuityDeviceConnected.java 0 → 100644 +74 −0 Original line number Diff line number Diff line /* * Copyright (C) 2025 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.server.companion.datatransfer.continuity.messages; import android.util.proto.ProtoInputStream; import android.util.proto.ProtoOutputStream; import android.util.proto.ProtoParseException; import java.io.IOException; /** * Deserialized version of the {@link ContinuityDeviceConnected} proto. */ public class ContinuityDeviceConnected implements TaskContinuityMessageData { private int mCurrentForegroundTaskId = 0; public ContinuityDeviceConnected(int currentForegroundTaskId) { mCurrentForegroundTaskId = currentForegroundTaskId; } ContinuityDeviceConnected(ProtoInputStream pis) throws IOException, ProtoParseException { boolean hasReadForegroundTaskId = false; while (pis.nextField() != ProtoInputStream.NO_MORE_FIELDS) { switch (pis.getFieldNumber()) { case (int) android.companion.ContinuityDeviceConnected.CURRENT_FOREGROUND_TASK_ID: mCurrentForegroundTaskId = pis.readInt( android.companion.ContinuityDeviceConnected.CURRENT_FOREGROUND_TASK_ID ); hasReadForegroundTaskId = true; break; } } if (!hasReadForegroundTaskId) { throw new ProtoParseException( "Missing required field: current_foreground_task_id"); } } /** * Returns the current foreground task ID. */ public int getCurrentForegroundTaskId() { return mCurrentForegroundTaskId; } /** * Writes this object to a proto output stream. */ @Override public void writeToProto(ProtoOutputStream pos) { pos.writeInt32( android.companion.ContinuityDeviceConnected.CURRENT_FOREGROUND_TASK_ID, mCurrentForegroundTaskId); } } No newline at end of file services/companion/java/com/android/server/companion/datatransfer/continuity/messages/TaskContinuityMessage.java 0 → 100644 +107 −0 Original line number Diff line number Diff line /* * Copyright (C) 2025 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.server.companion.datatransfer.continuity.messages; import android.util.proto.ProtoInputStream; import android.util.proto.ProtoOutputStream; import android.util.proto.ProtoParseException; import java.io.IOException; /** * Serialized version of the {@link TaskContinuityMessage} proto, allowing for * serialization and deserialization from bytes. */ public final class TaskContinuityMessage { private TaskContinuityMessageData mData; TaskContinuityMessage(Builder builder) { mData = builder.mData; } public TaskContinuityMessage(byte[] data) throws IOException, ProtoParseException { ProtoInputStream pis = new ProtoInputStream(data); while (pis.nextField() != ProtoInputStream.NO_MORE_FIELDS) { switch (pis.getFieldNumber()) { case (int) android.companion.TaskContinuityMessage.DEVICE_CONNECTED: final long deviceConnectedToken = pis.start( android.companion.TaskContinuityMessage.DEVICE_CONNECTED ); mData = new ContinuityDeviceConnected(pis); pis.end(deviceConnectedToken); break; } } } /** * Returns the value of the data field. */ public TaskContinuityMessageData getData() { return mData; } /** * Serializes this message to bytes. */ public byte[] toBytes() { ProtoOutputStream pos = new ProtoOutputStream(); switch (mData) { case ContinuityDeviceConnected continuityDeviceConnected: long token = pos.start( android.companion.TaskContinuityMessage.DEVICE_CONNECTED ); continuityDeviceConnected.writeToProto(pos); pos.end(token); break; default: break; } return pos.getBytes(); } /** * Builder for {@link TaskContinuityMessage}. */ public static final class Builder { private TaskContinuityMessageData mData; public Builder() { } /** * Sets the value of the data field. */ public Builder setData(TaskContinuityMessageData data) { mData = data; return this; } /** * Builds a {@link TaskContinuityMessage}. */ public TaskContinuityMessage build() { return new TaskContinuityMessage(this); } } } No newline at end of file Loading
core/java/android/companion/CompanionDeviceManager.java +6 −0 Original line number Diff line number Diff line Loading @@ -260,6 +260,12 @@ public final class CompanionDeviceManager { * @hide */ public static final int MESSAGE_REQUEST_CONTEXT_SYNC = 0x63678883; // ?CXS /** * Message header assigned to task continuity messages. * * @hide */ public static final int MESSAGE_TASK_CONTINUITY = 0x63678884; // ?TSK /** * Message header assigned to the permission restore request. * Loading
core/proto/android/companion/OWNERS +2 −0 Original line number Diff line number Diff line include /core/java/android/companion/OWNERS joeantonetti@google.com jackshira@google.com
core/proto/android/companion/task_continuity_message.proto 0 → 100644 +32 −0 Original line number Diff line number Diff line /* * Copyright (C) 2025 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ syntax = "proto3"; package android.companion; option java_multiple_files = true; // Next index: 2 message TaskContinuityMessage { oneof data { ContinuityDeviceConnected device_connected = 1; } } message ContinuityDeviceConnected { int32 currentForegroundTaskId = 1; }
services/companion/java/com/android/server/companion/datatransfer/continuity/messages/ContinuityDeviceConnected.java 0 → 100644 +74 −0 Original line number Diff line number Diff line /* * Copyright (C) 2025 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.server.companion.datatransfer.continuity.messages; import android.util.proto.ProtoInputStream; import android.util.proto.ProtoOutputStream; import android.util.proto.ProtoParseException; import java.io.IOException; /** * Deserialized version of the {@link ContinuityDeviceConnected} proto. */ public class ContinuityDeviceConnected implements TaskContinuityMessageData { private int mCurrentForegroundTaskId = 0; public ContinuityDeviceConnected(int currentForegroundTaskId) { mCurrentForegroundTaskId = currentForegroundTaskId; } ContinuityDeviceConnected(ProtoInputStream pis) throws IOException, ProtoParseException { boolean hasReadForegroundTaskId = false; while (pis.nextField() != ProtoInputStream.NO_MORE_FIELDS) { switch (pis.getFieldNumber()) { case (int) android.companion.ContinuityDeviceConnected.CURRENT_FOREGROUND_TASK_ID: mCurrentForegroundTaskId = pis.readInt( android.companion.ContinuityDeviceConnected.CURRENT_FOREGROUND_TASK_ID ); hasReadForegroundTaskId = true; break; } } if (!hasReadForegroundTaskId) { throw new ProtoParseException( "Missing required field: current_foreground_task_id"); } } /** * Returns the current foreground task ID. */ public int getCurrentForegroundTaskId() { return mCurrentForegroundTaskId; } /** * Writes this object to a proto output stream. */ @Override public void writeToProto(ProtoOutputStream pos) { pos.writeInt32( android.companion.ContinuityDeviceConnected.CURRENT_FOREGROUND_TASK_ID, mCurrentForegroundTaskId); } } No newline at end of file
services/companion/java/com/android/server/companion/datatransfer/continuity/messages/TaskContinuityMessage.java 0 → 100644 +107 −0 Original line number Diff line number Diff line /* * Copyright (C) 2025 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.server.companion.datatransfer.continuity.messages; import android.util.proto.ProtoInputStream; import android.util.proto.ProtoOutputStream; import android.util.proto.ProtoParseException; import java.io.IOException; /** * Serialized version of the {@link TaskContinuityMessage} proto, allowing for * serialization and deserialization from bytes. */ public final class TaskContinuityMessage { private TaskContinuityMessageData mData; TaskContinuityMessage(Builder builder) { mData = builder.mData; } public TaskContinuityMessage(byte[] data) throws IOException, ProtoParseException { ProtoInputStream pis = new ProtoInputStream(data); while (pis.nextField() != ProtoInputStream.NO_MORE_FIELDS) { switch (pis.getFieldNumber()) { case (int) android.companion.TaskContinuityMessage.DEVICE_CONNECTED: final long deviceConnectedToken = pis.start( android.companion.TaskContinuityMessage.DEVICE_CONNECTED ); mData = new ContinuityDeviceConnected(pis); pis.end(deviceConnectedToken); break; } } } /** * Returns the value of the data field. */ public TaskContinuityMessageData getData() { return mData; } /** * Serializes this message to bytes. */ public byte[] toBytes() { ProtoOutputStream pos = new ProtoOutputStream(); switch (mData) { case ContinuityDeviceConnected continuityDeviceConnected: long token = pos.start( android.companion.TaskContinuityMessage.DEVICE_CONNECTED ); continuityDeviceConnected.writeToProto(pos); pos.end(token); break; default: break; } return pos.getBytes(); } /** * Builder for {@link TaskContinuityMessage}. */ public static final class Builder { private TaskContinuityMessageData mData; public Builder() { } /** * Sets the value of the data field. */ public Builder setData(TaskContinuityMessageData data) { mData = data; return this; } /** * Builds a {@link TaskContinuityMessage}. */ public TaskContinuityMessage build() { return new TaskContinuityMessage(this); } } } No newline at end of file