Loading packages/SystemUI/shared/src/com/android/systemui/shared/mediattt/DeviceInfo.aidl 0 → 100644 +19 −0 Original line number Diff line number Diff line /* * Copyright (C) 2022 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.systemui.shared.mediattt; parcelable DeviceInfo; packages/SystemUI/shared/src/com/android/systemui/shared/mediattt/DeviceInfo.kt 0 → 100644 +41 −0 Original line number Diff line number Diff line /* * Copyright (C) 2022 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.systemui.shared.mediattt import android.os.Parcel import android.os.Parcelable /** * Represents a device that can send or receive media. Includes any device information necessary for * SysUI to display an informative chip to the user. */ class DeviceInfo(val name: String) : Parcelable { constructor(parcel: Parcel) : this(parcel.readString()) override fun writeToParcel(dest: Parcel?, flags: Int) { dest?.writeString(name) } override fun describeContents() = 0 override fun toString() = "name: $name" companion object CREATOR : Parcelable.Creator<DeviceInfo> { override fun createFromParcel(parcel: Parcel) = DeviceInfo(parcel) override fun newArray(size: Int) = arrayOfNulls<DeviceInfo?>(size) } } packages/SystemUI/shared/src/com/android/systemui/shared/mediattt/IDeviceSenderCallback.aidl +3 −2 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.systemui.shared.mediattt; import android.media.MediaRoute2Info; import com.android.systemui.shared.mediattt.DeviceInfo; /** * A callback interface that can be invoked to trigger media transfer events on System UI. Loading @@ -40,6 +41,6 @@ interface IDeviceSenderCallback { * playing media locally and the media should be transferred to be played on the receiver * device instead. */ // TODO(b/203800643): Add the otherDeviceInfo parameter. oneway void closeToReceiverToStartCast(in MediaRoute2Info mediaInfo); oneway void closeToReceiverToStartCast( in MediaRoute2Info mediaInfo, in DeviceInfo otherDeviceInfo); } packages/SystemUI/src/com/android/systemui/media/taptotransfer/MediaTttCommandLineHelper.kt +3 −1 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ import com.android.systemui.media.taptotransfer.sender.MediaTttSenderService import com.android.systemui.media.taptotransfer.sender.MoveCloserToStartCast import com.android.systemui.media.taptotransfer.sender.TransferInitiated import com.android.systemui.media.taptotransfer.sender.TransferSucceeded import com.android.systemui.shared.mediattt.DeviceInfo import com.android.systemui.shared.mediattt.IDeviceSenderCallback import com.android.systemui.statusbar.commandline.Command import com.android.systemui.statusbar.commandline.CommandRegistry Loading Loading @@ -81,11 +82,12 @@ class MediaTttCommandLineHelper @Inject constructor( val mediaInfo = MediaRoute2Info.Builder("id", "Test Name") .addFeature("feature") .build() val otherDeviceInfo = DeviceInfo(otherDeviceName) when (args[1]) { MOVE_CLOSER_TO_START_CAST_COMMAND_NAME -> { runOnService { senderCallback -> senderCallback.closeToReceiverToStartCast(mediaInfo) senderCallback.closeToReceiverToStartCast(mediaInfo, otherDeviceInfo) } } Loading packages/SystemUI/src/com/android/systemui/media/taptotransfer/sender/MediaTttSenderService.kt +9 −6 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import android.graphics.drawable.Icon import android.media.MediaRoute2Info import android.os.IBinder import com.android.systemui.R import com.android.systemui.shared.mediattt.DeviceInfo import com.android.systemui.shared.mediattt.IDeviceSenderCallback import javax.inject.Inject Loading @@ -37,8 +38,10 @@ class MediaTttSenderService @Inject constructor( // TODO(b/203800643): Add logging when callbacks trigger. private val binder: IBinder = object : IDeviceSenderCallback.Stub() { override fun closeToReceiverToStartCast(mediaInfo: MediaRoute2Info) { this@MediaTttSenderService.closeToReceiverToStartCast(mediaInfo) override fun closeToReceiverToStartCast( mediaInfo: MediaRoute2Info, otherDeviceInfo: DeviceInfo ) { this@MediaTttSenderService.closeToReceiverToStartCast(mediaInfo, otherDeviceInfo) } } Loading @@ -50,14 +53,14 @@ class MediaTttSenderService @Inject constructor( override fun onBind(intent: Intent?): IBinder = binder private fun closeToReceiverToStartCast(mediaInfo: MediaRoute2Info) { private fun closeToReceiverToStartCast( mediaInfo: MediaRoute2Info, otherDeviceInfo: DeviceInfo ) { val chipState = MoveCloserToStartCast( appIconDrawable = fakeAppIconDrawable, appIconContentDescription = mediaInfo.name.toString(), otherDeviceName = FAKE_DEVICE_NAME otherDeviceName = otherDeviceInfo.name ) controller.displayChip(chipState) } } private const val FAKE_DEVICE_NAME = "Fake Other Device Name" Loading
packages/SystemUI/shared/src/com/android/systemui/shared/mediattt/DeviceInfo.aidl 0 → 100644 +19 −0 Original line number Diff line number Diff line /* * Copyright (C) 2022 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.systemui.shared.mediattt; parcelable DeviceInfo;
packages/SystemUI/shared/src/com/android/systemui/shared/mediattt/DeviceInfo.kt 0 → 100644 +41 −0 Original line number Diff line number Diff line /* * Copyright (C) 2022 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.systemui.shared.mediattt import android.os.Parcel import android.os.Parcelable /** * Represents a device that can send or receive media. Includes any device information necessary for * SysUI to display an informative chip to the user. */ class DeviceInfo(val name: String) : Parcelable { constructor(parcel: Parcel) : this(parcel.readString()) override fun writeToParcel(dest: Parcel?, flags: Int) { dest?.writeString(name) } override fun describeContents() = 0 override fun toString() = "name: $name" companion object CREATOR : Parcelable.Creator<DeviceInfo> { override fun createFromParcel(parcel: Parcel) = DeviceInfo(parcel) override fun newArray(size: Int) = arrayOfNulls<DeviceInfo?>(size) } }
packages/SystemUI/shared/src/com/android/systemui/shared/mediattt/IDeviceSenderCallback.aidl +3 −2 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.systemui.shared.mediattt; import android.media.MediaRoute2Info; import com.android.systemui.shared.mediattt.DeviceInfo; /** * A callback interface that can be invoked to trigger media transfer events on System UI. Loading @@ -40,6 +41,6 @@ interface IDeviceSenderCallback { * playing media locally and the media should be transferred to be played on the receiver * device instead. */ // TODO(b/203800643): Add the otherDeviceInfo parameter. oneway void closeToReceiverToStartCast(in MediaRoute2Info mediaInfo); oneway void closeToReceiverToStartCast( in MediaRoute2Info mediaInfo, in DeviceInfo otherDeviceInfo); }
packages/SystemUI/src/com/android/systemui/media/taptotransfer/MediaTttCommandLineHelper.kt +3 −1 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ import com.android.systemui.media.taptotransfer.sender.MediaTttSenderService import com.android.systemui.media.taptotransfer.sender.MoveCloserToStartCast import com.android.systemui.media.taptotransfer.sender.TransferInitiated import com.android.systemui.media.taptotransfer.sender.TransferSucceeded import com.android.systemui.shared.mediattt.DeviceInfo import com.android.systemui.shared.mediattt.IDeviceSenderCallback import com.android.systemui.statusbar.commandline.Command import com.android.systemui.statusbar.commandline.CommandRegistry Loading Loading @@ -81,11 +82,12 @@ class MediaTttCommandLineHelper @Inject constructor( val mediaInfo = MediaRoute2Info.Builder("id", "Test Name") .addFeature("feature") .build() val otherDeviceInfo = DeviceInfo(otherDeviceName) when (args[1]) { MOVE_CLOSER_TO_START_CAST_COMMAND_NAME -> { runOnService { senderCallback -> senderCallback.closeToReceiverToStartCast(mediaInfo) senderCallback.closeToReceiverToStartCast(mediaInfo, otherDeviceInfo) } } Loading
packages/SystemUI/src/com/android/systemui/media/taptotransfer/sender/MediaTttSenderService.kt +9 −6 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import android.graphics.drawable.Icon import android.media.MediaRoute2Info import android.os.IBinder import com.android.systemui.R import com.android.systemui.shared.mediattt.DeviceInfo import com.android.systemui.shared.mediattt.IDeviceSenderCallback import javax.inject.Inject Loading @@ -37,8 +38,10 @@ class MediaTttSenderService @Inject constructor( // TODO(b/203800643): Add logging when callbacks trigger. private val binder: IBinder = object : IDeviceSenderCallback.Stub() { override fun closeToReceiverToStartCast(mediaInfo: MediaRoute2Info) { this@MediaTttSenderService.closeToReceiverToStartCast(mediaInfo) override fun closeToReceiverToStartCast( mediaInfo: MediaRoute2Info, otherDeviceInfo: DeviceInfo ) { this@MediaTttSenderService.closeToReceiverToStartCast(mediaInfo, otherDeviceInfo) } } Loading @@ -50,14 +53,14 @@ class MediaTttSenderService @Inject constructor( override fun onBind(intent: Intent?): IBinder = binder private fun closeToReceiverToStartCast(mediaInfo: MediaRoute2Info) { private fun closeToReceiverToStartCast( mediaInfo: MediaRoute2Info, otherDeviceInfo: DeviceInfo ) { val chipState = MoveCloserToStartCast( appIconDrawable = fakeAppIconDrawable, appIconContentDescription = mediaInfo.name.toString(), otherDeviceName = FAKE_DEVICE_NAME otherDeviceName = otherDeviceInfo.name ) controller.displayChip(chipState) } } private const val FAKE_DEVICE_NAME = "Fake Other Device Name"