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.companion.virtual.sensor; 18 19 import android.companion.virtual.sensor.VirtualSensor; 20 import android.os.SharedMemory; 21 22 /** 23 * Interface for notifying the sensor owner about whether and how sensor events should be injected. 24 * 25 * @hide 26 */ 27 oneway interface IVirtualSensorCallback { 28 29 /** 30 * Called when the requested sensor event injection parameters have changed. 31 * 32 * @param sensor The sensor whose requested injection parameters have changed. 33 * @param enabled Whether the sensor is enabled. 34 * @param samplingPeriodMicros The requested sensor's sampling period in microseconds. 35 * @param batchReportingLatencyMicros The requested maximum time interval in microseconds 36 * between the delivery of two batches of sensor events. 37 */ onConfigurationChanged(in VirtualSensor sensor, boolean enabled, int samplingPeriodMicros, int batchReportLatencyMicros)38 void onConfigurationChanged(in VirtualSensor sensor, boolean enabled, int samplingPeriodMicros, 39 int batchReportLatencyMicros); 40 41 /** 42 * Called when a sensor direct channel is created. 43 * 44 * @param channelHandle Identifier of the channel that was created. 45 * @param sharedMemory The shared memory region for the direct sensor channel. 46 */ onDirectChannelCreated(int channelHandle, in SharedMemory sharedMemory)47 void onDirectChannelCreated(int channelHandle, in SharedMemory sharedMemory); 48 49 /** 50 * Called when a sensor direct channel is destroyed. 51 * 52 * @param channelHandle Identifier of the channel that was destroyed. 53 */ onDirectChannelDestroyed(int channelHandle)54 void onDirectChannelDestroyed(int channelHandle); 55 56 /** 57 * Called when a sensor direct channel is configured. 58 * 59 * @param channelHandle Identifier of the channel that was configured. 60 * @param sensor The sensor, for which the channel was configured. 61 * @param rateLevel The rate level used to configure the direct sensor channel. 62 * @param reportToken A positive sensor report token, used to differentiate between events from 63 * different sensors within the same channel. 64 */ onDirectChannelConfigured(int channelHandle, in VirtualSensor sensor, int rateLevel, int reportToken)65 void onDirectChannelConfigured(int channelHandle, in VirtualSensor sensor, int rateLevel, 66 int reportToken); 67 } 68