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

Commit 8333b4f4 authored by Caitlin Cassidy's avatar Caitlin Cassidy Committed by Android (Google) Code Review
Browse files

Merge "[Output Switcher] Implement nearby device callbacks."

parents d95e7a66 3594077b
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -879,6 +879,12 @@
            android:name=".media.taptotransfer.sender.MediaTttSenderService"
           />

        <!-- Service for external clients to notify us of nearby media devices -->
        <!-- TODO(b/216313420): Export and guard with a permission. -->
        <service
            android:name=".media.nearby.NearbyMediaDevicesService"
            />

        <receiver
            android:name=".tuner.TunerService$ClearReceiver"
            android:exported="false">
+43 −0
Original line number Diff line number Diff line
@@ -14,38 +14,30 @@
 * limitations under the License.
 */

package com.android.systemui.media.nearby
package com.android.systemui.shared.media;

import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.shared.media.INearbyMediaDevicesUpdateCallback;
import com.android.systemui.shared.media.NearbyDevice;

/**
 * A manager that returns information about devices that are nearby and can receive media transfers.
 * An interface that provides information about nearby devices that are able to play media.
 *
 * External clients will implement this interface and System UI will invoke it if it's passed to
 * SystemUI via {@link INearbyMediaDevicesService.registerProvider}.
 */
@SysUISingleton
class MediaNearbyDevicesManager {

    /** Returns a list containing the current nearby devices. */
    fun getCurrentNearbyDevices(): List<NearbyDevice> {
        // TODO(b/216313420): Implement this function.
        return emptyList()
    }
interface INearbyMediaDevicesProvider {
  /**
   * Returns a list of nearby devices that are able to play media.
   */
  List<NearbyDevice> getCurrentNearbyDevices() = 1;

  /**
     * Registers [callback] to be notified each time a device's range changes or when a new device
     * comes within range.
   * Registers a callback that will be notified each time the status of a nearby device changes.
   */
    fun registerNearbyDevicesCallback(
        callback: (device: NearbyDevice) -> Unit
    ) {
        // TODO(b/216313420): Implement this function.
    }
  oneway void registerNearbyDevicesCallback(in INearbyMediaDevicesUpdateCallback callback) = 2;

  /**
     * Un-registers [callback]. See [registerNearbyDevicesCallback].
   * Unregisters a callback. See {@link registerNearbyDevicesCallback}.
   */
    fun unregisterNearbyDevicesCallback(
        callback: (device: NearbyDevice) -> Unit
    ) {
        // TODO(b/216313420): Implement this function.
    }
  oneway void unregisterNearbyDevicesCallback(in INearbyMediaDevicesUpdateCallback callback) = 3;
}
+33 −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.media;

import com.android.systemui.shared.media.INearbyMediaDevicesProvider;

/**
 * An interface that can be invoked to notify System UI of nearby media devices.
 *
 * External clients wanting to notify System UI about the status of nearby media devices should
 * implement {@link INearbyMediaDevicesProvider} and then register it with system UI using this
 * service.
 *
 * System UI will implement this interface and external clients will invoke it.
 */
interface INearbyMediaDevicesService {
  /** Registers a new provider. */
  oneway void registerProvider(INearbyMediaDevicesProvider provider) = 1;
}
+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.media;

/**
 * A callback used to notify implementors of changes in the status of nearby devices that are able
 * to play media.
 *
 * External clients may allow registration of these callbacks and external clients will be
 * responsible for notifying the callbacks appropriately. System UI is only a mediator between the
 * external client and these callbacks.
 */
interface INearbyMediaDevicesUpdateCallback {
    /** Unknown distance range. */
    const int RANGE_UNKNOWN = 0;
    /** Distance is very far away from the peer device. */
    const int RANGE_FAR = 1;
    /** Distance is relatively long from the peer device, typically a few meters. */
    const int RANGE_LONG = 2;
    /** Distance is close to the peer device, typically with one or two meter. */
    const int RANGE_CLOSE = 3;
    /** Distance is very close to the peer device, typically within one meter or less. */
    const int RANGE_WITHIN_REACH = 4;

    /** Invoked by external clients when media device changes are detected. */
    oneway void nearbyDeviceUpdate(in String routeId, in int rangeZone) = 1;
}
+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.media;

parcelable NearbyDevice;
Loading