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.view.inputmethod; 18 19 import android.annotation.Nullable; 20 import android.view.WindowManager.LayoutParams.SoftInputModeFlags; 21 22 import com.android.internal.inputmethod.StartInputFlags; 23 import com.android.internal.inputmethod.StartInputReason; 24 import com.android.internal.view.IInputMethodManager; 25 26 /** 27 * This data class is a container for storing the last arguments used when calling into 28 * {@link IInputMethodManager#startInputOrWindowGainedFocus}. They are used to determine if we 29 * are switching from a non-editable view to another non-editable view, in which case we avoid 30 * a binder call into the {@link com.android.server.inputmethod.InputMethodManagerService}. 31 */ 32 final class ViewFocusParameterInfo { 33 @Nullable final EditorInfo mPreviousEditorInfo; 34 @StartInputFlags final int mPreviousStartInputFlags; 35 @StartInputReason final int mPreviousStartInputReason; 36 @SoftInputModeFlags final int mPreviousSoftInputMode; 37 final int mPreviousWindowFlags; 38 ViewFocusParameterInfo(@ullable EditorInfo previousEditorInfo, @StartInputFlags int previousStartInputFlags, @StartInputReason int previousStartInputReason, @SoftInputModeFlags int previousSoftInputMode, int previousWindowFlags)39 ViewFocusParameterInfo(@Nullable EditorInfo previousEditorInfo, 40 @StartInputFlags int previousStartInputFlags, 41 @StartInputReason int previousStartInputReason, 42 @SoftInputModeFlags int previousSoftInputMode, 43 int previousWindowFlags) { 44 mPreviousEditorInfo = previousEditorInfo; 45 mPreviousStartInputFlags = previousStartInputFlags; 46 mPreviousStartInputReason = previousStartInputReason; 47 mPreviousSoftInputMode = previousSoftInputMode; 48 mPreviousWindowFlags = previousWindowFlags; 49 } 50 sameAs(@ullable EditorInfo currentEditorInfo, @StartInputFlags int startInputFlags, @StartInputReason int startInputReason, @SoftInputModeFlags int softInputMode, int windowFlags)51 boolean sameAs(@Nullable EditorInfo currentEditorInfo, 52 @StartInputFlags int startInputFlags, 53 @StartInputReason int startInputReason, 54 @SoftInputModeFlags int softInputMode, 55 int windowFlags) { 56 return mPreviousStartInputFlags == startInputFlags 57 && mPreviousStartInputReason == startInputReason 58 && mPreviousSoftInputMode == softInputMode 59 && mPreviousWindowFlags == windowFlags 60 && (mPreviousEditorInfo == currentEditorInfo 61 || (mPreviousEditorInfo != null 62 && mPreviousEditorInfo.kindofEquals(currentEditorInfo))); 63 } 64 } 65