1 /* 2 * Copyright 2024 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.view.cts.util; 18 19 import android.view.KeyEvent; 20 import android.view.MotionEvent; 21 import android.window.InputTransferToken; 22 23 public class ASurfaceControlInputReceiverTestUtils { 24 static { 25 System.loadLibrary("ctssurfacecontrol_jni"); 26 } 27 28 public interface InputReceiver { 29 /** 30 * Invoked when the surface control received a motion event. 31 */ onMotionEvent(MotionEvent motionEvent)32 boolean onMotionEvent(MotionEvent motionEvent); 33 /** 34 * Invoked when the surface control received a key event. 35 */ onKeyEvent(KeyEvent keyEvent)36 boolean onKeyEvent(KeyEvent keyEvent); 37 } 38 39 /** 40 * Create a native input receiver for a SurfaceControl 41 */ nCreateInputReceiver(boolean batched, InputTransferToken hostToken, long aSurfaceControl, InputReceiver inputReceiver)42 public static native long nCreateInputReceiver(boolean batched, InputTransferToken hostToken, 43 long aSurfaceControl, InputReceiver inputReceiver); 44 45 /** 46 * Deletes the native input receiver 47 */ nDeleteInputReceiver(long aInputReceiver)48 public static native void nDeleteInputReceiver(long aInputReceiver); 49 50 /** 51 * Get the input transfer token for the registered native receiver 52 */ nGetInputTransferToken(long aInputReceiver)53 public static native InputTransferToken nGetInputTransferToken(long aInputReceiver); 54 } 55