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.seeker.events 18 19 import android.nearby.NearbyDevice 20 import android.nearby.ScanCallback 21 import com.google.android.mobly.snippet.util.postSnippetEvent 22 23 /** The Mobly snippet events to report to the Python side. */ 24 class ScanCallbackEvents(private val callbackId: String) : ScanCallback { 25 onDiscoverednull26 override fun onDiscovered(device: NearbyDevice) { 27 postSnippetEvent(callbackId, "onDiscovered") { 28 putString("device", device.toString()) 29 } 30 } 31 onUpdatednull32 override fun onUpdated(device: NearbyDevice) { 33 postSnippetEvent(callbackId, "onUpdated") { 34 putString("device", device.toString()) 35 } 36 } 37 onLostnull38 override fun onLost(device: NearbyDevice) { 39 postSnippetEvent(callbackId, "onLost") { 40 putString("device", device.toString()) 41 } 42 } 43 }