1 /* 2 * Copyright (C) 2022 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package android.nearby.multidevices.fastpair.provider.events 18 19 import android.nearby.multidevices.fastpair.provider.controller.FastPairProviderSimulatorController 20 import com.google.android.mobly.snippet.util.postSnippetEvent 21 22 /** The Mobly snippet events to report to the Python side. */ 23 class ProviderStatusEvents(private val callbackId: String) : 24 FastPairProviderSimulatorController.EventListener { 25 26 /** Reports the first onServiceConnected of A2DP sink profile. */ onA2DPSinkProfileConnectednull27 override fun onA2DPSinkProfileConnected() { 28 postSnippetEvent(callbackId, "onA2DPSinkProfileConnected") {} 29 } 30 31 /** 32 * Indicates the Bluetooth scan mode of the Fast Pair provider simulator has changed. 33 * 34 * @param mode the current scan mode in String mapping by [FastPairSimulator#scanModeToString]. 35 */ onScanModeChangenull36 override fun onScanModeChange(mode: String) { 37 postSnippetEvent(callbackId, "onScanModeChange") { putString("mode", mode) } 38 } 39 40 /** 41 * Indicates the advertising state of the Fast Pair provider simulator has changed. 42 * 43 * @param isAdvertising the current advertising state, true if advertising otherwise false. 44 */ onAdvertisingChangenull45 override fun onAdvertisingChange(isAdvertising: Boolean) { 46 postSnippetEvent(callbackId, "onAdvertisingChange") { 47 putBoolean("isAdvertising", isAdvertising) 48 } 49 } 50 }