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 com.android.internal.inputmethod; 18 19 import android.view.inputmethod.ImeTracker; 20 21 import com.android.internal.infra.AndroidFuture; 22 23 /** 24 * Interface to the global IME tracker service, used by all client applications. 25 * {@hide} 26 */ 27 interface IImeTracker { 28 29 /** 30 * Called when an IME request is started. 31 * 32 * @param tag the logging tag. 33 * @param uid the uid of the client that started the request. 34 * @param type the type of the request. 35 * @param origin the origin of the request. 36 * @param fromUser whether this request was created directly from user interaction. 37 * @param reason the reason for starting the request. 38 * 39 * @return An IME request tracking token. 40 */ onStart(String tag, int uid, int type, int origin, int reason, boolean fromUser)41 ImeTracker.Token onStart(String tag, int uid, int type, int origin, int reason, 42 boolean fromUser); 43 44 /** 45 * Called when the IME request progresses to a further phase. 46 * 47 * @param binder the binder of token tracking the current IME request. 48 * @param phase the new phase the IME request reached. 49 */ onProgress(in IBinder binder, int phase)50 oneway void onProgress(in IBinder binder, int phase); 51 52 /** 53 * Called when the IME request fails. 54 * 55 * @param statsToken the token tracking the current IME request. 56 * @param phase the phase the IME request failed at. 57 */ onFailed(in ImeTracker.Token statsToken, int phase)58 oneway void onFailed(in ImeTracker.Token statsToken, int phase); 59 60 /** 61 * Called when the IME request is cancelled. 62 * 63 * @param statsToken the token tracking the current IME request. 64 * @param phase the phase the IME request was cancelled at. 65 */ onCancelled(in ImeTracker.Token statsToken, int phase)66 oneway void onCancelled(in ImeTracker.Token statsToken, int phase); 67 68 /** 69 * Called when the show IME request is successful. 70 * 71 * @param statsToken the token tracking the current IME request. 72 */ onShown(in ImeTracker.Token statsToken)73 oneway void onShown(in ImeTracker.Token statsToken); 74 75 /** 76 * Called when the hide IME request is successful. 77 * 78 * @param statsToken the token tracking the current IME request. 79 */ onHidden(in ImeTracker.Token statsToken)80 oneway void onHidden(in ImeTracker.Token statsToken); 81 82 /** 83 * Called when the user-controlled IME request was dispatched to the requesting app. The 84 * user animation can take an undetermined amount of time, so it shouldn't be tracked. 85 * 86 * @param statsToken the token tracking the current IME request. 87 */ onDispatched(in ImeTracker.Token statsToken)88 oneway void onDispatched(in ImeTracker.Token statsToken); 89 90 /** 91 * Checks whether there are any pending IME visibility requests. 92 * 93 * @return {@code true} iff there are pending IME visibility requests. 94 */ 95 @EnforcePermission("TEST_INPUT_METHOD") 96 @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = " 97 + "android.Manifest.permission.TEST_INPUT_METHOD)") hasPendingImeVisibilityRequests()98 boolean hasPendingImeVisibilityRequests(); 99 100 /** 101 * Finishes the tracking of any pending IME visibility requests. This won't stop the actual 102 * requests, but allows resetting the state when starting up test runs. 103 * 104 * @param completionSignal used to signal when the tracking has been finished. 105 */ 106 @EnforcePermission("TEST_INPUT_METHOD") 107 @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = " 108 + "android.Manifest.permission.TEST_INPUT_METHOD)") finishTrackingPendingImeVisibilityRequests( in AndroidFuture completionSignal )109 oneway void finishTrackingPendingImeVisibilityRequests( 110 in AndroidFuture completionSignal /* T=Void */); 111 } 112