[Output Switcher] Add a manager class that handles requests for nearby
devices. Test: compiles Bug: 216313420 Change-Id: Iba79fbf4c5382a6c92be66f9f2f5e8b23893b4bd
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* 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.media.nearby
|
||||
|
||||
import com.android.systemui.dagger.SysUISingleton
|
||||
|
||||
/**
|
||||
* A manager that returns information about devices that are nearby and can receive media transfers.
|
||||
*/
|
||||
@SysUISingleton
|
||||
class MediaNearbyDevicesManager {
|
||||
|
||||
/** Returns a list containing the current nearby devices. */
|
||||
fun getCurrentNearbyDevices(): List<NearbyDevice> {
|
||||
// TODO(b/216313420): Implement this function.
|
||||
return emptyList()
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers [callback] to be notified each time a device's range changes or when a new device
|
||||
* comes within range.
|
||||
*/
|
||||
fun registerNearbyDevicesCallback(
|
||||
callback: (device: NearbyDevice) -> Unit
|
||||
) {
|
||||
// TODO(b/216313420): Implement this function.
|
||||
}
|
||||
|
||||
/**
|
||||
* Un-registers [callback]. See [registerNearbyDevicesCallback].
|
||||
*/
|
||||
fun unregisterNearbyDevicesCallback(
|
||||
callback: (device: NearbyDevice) -> Unit
|
||||
) {
|
||||
// TODO(b/216313420): Implement this function.
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* 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.media.nearby
|
||||
|
||||
import android.os.Parcel
|
||||
import android.os.Parcelable
|
||||
|
||||
/**
|
||||
* A parcelable representing a nearby device that can be used for media transfer.
|
||||
*
|
||||
* This class includes:
|
||||
* - [routeId] identifying the media route
|
||||
* - [rangeZone] specifying how far away the device with the media route is from this device.
|
||||
*/
|
||||
class NearbyDevice(parcel: Parcel) : Parcelable {
|
||||
var routeId: String? = null
|
||||
@RangeZone val rangeZone: Int
|
||||
|
||||
init {
|
||||
routeId = parcel.readString() ?: "unknown"
|
||||
rangeZone = parcel.readInt()
|
||||
}
|
||||
|
||||
override fun describeContents() = 0
|
||||
|
||||
override fun writeToParcel(out: Parcel, flags: Int) {
|
||||
out.writeString(routeId)
|
||||
out.writeInt(rangeZone)
|
||||
}
|
||||
|
||||
companion object CREATOR : Parcelable.Creator<NearbyDevice?> {
|
||||
override fun createFromParcel(parcel: Parcel) = NearbyDevice(parcel)
|
||||
override fun newArray(size: Int) = arrayOfNulls<NearbyDevice?>(size)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* 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.media.nearby
|
||||
|
||||
import androidx.annotation.IntDef
|
||||
import kotlin.annotation.AnnotationRetention
|
||||
|
||||
@IntDef(
|
||||
RangeZone.RANGE_UNKNOWN,
|
||||
RangeZone.RANGE_FAR,
|
||||
RangeZone.RANGE_LONG,
|
||||
RangeZone.RANGE_CLOSE,
|
||||
RangeZone.RANGE_WITHIN_REACH
|
||||
)
|
||||
@Retention(AnnotationRetention.SOURCE)
|
||||
/** The various range zones a device can be in, in relation to the current device. */
|
||||
annotation class RangeZone {
|
||||
companion object {
|
||||
/** Unknown distance range. */
|
||||
const val RANGE_UNKNOWN = 0
|
||||
/** Distance is very far away from the peer device. */
|
||||
const val RANGE_FAR = 1
|
||||
/** Distance is relatively long from the peer device, typically a few meters. */
|
||||
const val RANGE_LONG = 2
|
||||
/** Distance is close to the peer device, typically with one or two meter. */
|
||||
const val RANGE_CLOSE = 3
|
||||
/** Distance is very close to the peer device, typically within one meter or less. */
|
||||
const val RANGE_WITHIN_REACH = 4
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user