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 /**
22  * Interface to the global IME tracker service, used by all client applications.
23  * {@hide}
24  */
25 interface IImeTracker {
26 
27     /**
28      * Called when an IME show request is created.
29      *
30      * @param tag the logging tag.
31      * @param uid the uid of the client that requested the IME.
32      * @param origin the origin of the IME show request.
33      * @param reason the reason why the IME show request was created.
34      * @return A new IME tracking token.
35      */
onRequestShow(String tag, int uid, int origin, int reason)36     ImeTracker.Token onRequestShow(String tag, int uid, int origin, int reason);
37 
38     /**
39      * Called when an IME hide request is created.
40      *
41      * @param tag the logging tag.
42      * @param uid the uid of the client that requested the IME.
43      * @param origin the origin of the IME hide request.
44      * @param reason the reason why the IME hide request was created.
45      * @return A new IME tracking token.
46      */
onRequestHide(String tag, int uid, int origin, int reason)47     ImeTracker.Token onRequestHide(String tag, int uid, int origin, int reason);
48 
49     /**
50      * Called when the IME request progresses to a further phase.
51      *
52      * @param binder the binder of token tracking the current IME request.
53      * @param phase the new phase the IME request reached.
54      */
onProgress(in IBinder binder, int phase)55     oneway void onProgress(in IBinder binder, int phase);
56 
57     /**
58      * Called when the IME request fails.
59      *
60      * @param statsToken the token tracking the current IME request.
61      * @param phase the phase the IME request failed at.
62      */
onFailed(in ImeTracker.Token statsToken, int phase)63     oneway void onFailed(in ImeTracker.Token statsToken, int phase);
64 
65     /**
66      * Called when the IME request is cancelled.
67      *
68      * @param statsToken the token tracking the current IME request.
69      * @param phase the phase the IME request was cancelled at.
70      */
onCancelled(in ImeTracker.Token statsToken, int phase)71     oneway void onCancelled(in ImeTracker.Token statsToken, int phase);
72 
73     /**
74      * Called when the IME show request is successful.
75      *
76      * @param statsToken the token tracking the current IME request.
77      */
onShown(in ImeTracker.Token statsToken)78     oneway void onShown(in ImeTracker.Token statsToken);
79 
80     /**
81      * Called when the IME hide request is successful.
82      *
83      * @param statsToken the token tracking the current IME request.
84      */
onHidden(in ImeTracker.Token statsToken)85     oneway void onHidden(in ImeTracker.Token statsToken);
86 
87     /**
88      * Checks whether there are any pending IME visibility requests.
89      *
90      * @return {@code true} iff there are pending IME visibility requests.
91      */
92     @EnforcePermission("TEST_INPUT_METHOD")
93     @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = "
94             + "android.Manifest.permission.TEST_INPUT_METHOD)")
hasPendingImeVisibilityRequests()95     boolean hasPendingImeVisibilityRequests();
96 }
97