Merge "Revert "Cleanup IME window visibility flag logic"" into udc-qpr-dev am: f7a56fbd6e
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/23813063 Change-Id: Iefe3d1c1ed6740ea9c1811eddd8e82cd1fd291db Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -52,6 +52,8 @@ import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
|
||||
import static android.view.WindowInsets.Type.navigationBars;
|
||||
import static android.view.WindowInsets.Type.statusBars;
|
||||
|
||||
import static java.lang.annotation.RetentionPolicy.SOURCE;
|
||||
|
||||
import android.annotation.AnyThread;
|
||||
import android.annotation.CallSuper;
|
||||
import android.annotation.DrawableRes;
|
||||
@@ -158,7 +160,6 @@ import com.android.internal.inputmethod.InputMethodNavButtonFlags;
|
||||
import com.android.internal.inputmethod.InputMethodPrivilegedOperations;
|
||||
import com.android.internal.inputmethod.InputMethodPrivilegedOperationsRegistry;
|
||||
import com.android.internal.inputmethod.SoftInputShowHideReason;
|
||||
import com.android.internal.util.Preconditions;
|
||||
import com.android.internal.util.RingBuffer;
|
||||
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
@@ -481,53 +482,43 @@ public class InputMethodService extends AbstractInputMethodService {
|
||||
public static final int BACK_DISPOSITION_ADJUST_NOTHING = 3;
|
||||
|
||||
/**
|
||||
* Enum values to be used for {@link #setBackDisposition(int)}.
|
||||
* Enum flag to be used for {@link #setBackDisposition(int)}.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@IntDef(prefix = { "BACK_DISPOSITION_" }, value = {
|
||||
BACK_DISPOSITION_DEFAULT,
|
||||
BACK_DISPOSITION_WILL_NOT_DISMISS,
|
||||
BACK_DISPOSITION_WILL_DISMISS,
|
||||
BACK_DISPOSITION_ADJUST_NOTHING,
|
||||
})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
@Retention(SOURCE)
|
||||
@IntDef(value = {BACK_DISPOSITION_DEFAULT, BACK_DISPOSITION_WILL_NOT_DISMISS,
|
||||
BACK_DISPOSITION_WILL_DISMISS, BACK_DISPOSITION_ADJUST_NOTHING},
|
||||
prefix = "BACK_DISPOSITION_")
|
||||
public @interface BackDispositionMode {}
|
||||
|
||||
/**
|
||||
* Enum flags to be used for {@link #setImeWindowStatus}, representing the current state of the
|
||||
* IME window visibility.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@IntDef(flag = true, prefix = { "IME_" }, value = {
|
||||
IME_ACTIVE,
|
||||
IME_VISIBLE,
|
||||
IME_VISIBLE_IMPERCEPTIBLE,
|
||||
})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface ImeWindowVisibility {}
|
||||
|
||||
/**
|
||||
* The IME is active. It may or may not be visible.
|
||||
* @hide
|
||||
*/
|
||||
public static final int IME_ACTIVE = 0x1;
|
||||
|
||||
/**
|
||||
* The IME is perceptibly visible to the user.
|
||||
* @hide
|
||||
* The IME is perceptibly visible to the user.
|
||||
*/
|
||||
public static final int IME_VISIBLE = 0x2;
|
||||
|
||||
/**
|
||||
* @hide
|
||||
* The IME is active and ready with views but set invisible.
|
||||
* This flag cannot be combined with {@link #IME_VISIBLE}.
|
||||
*/
|
||||
public static final int IME_INVISIBLE = 0x4;
|
||||
|
||||
/**
|
||||
* @hide
|
||||
* The IME is visible, but not yet perceptible to the user (e.g. fading in)
|
||||
* by {@link android.view.WindowInsetsController}.
|
||||
*
|
||||
* @see InputMethodManager#reportPerceptible
|
||||
* @hide
|
||||
*/
|
||||
public static final int IME_VISIBLE_IMPERCEPTIBLE = 0x4;
|
||||
public static final int IME_VISIBLE_IMPERCEPTIBLE = 0x8;
|
||||
|
||||
// Min and max values for back disposition.
|
||||
private static final int BACK_DISPOSITION_MIN = BACK_DISPOSITION_DEFAULT;
|
||||
@@ -640,18 +631,9 @@ public class InputMethodService extends AbstractInputMethodService {
|
||||
|
||||
int mStatusIcon;
|
||||
|
||||
/**
|
||||
* Latest value reported of back disposition mode.
|
||||
*/
|
||||
@BackDispositionMode
|
||||
int mBackDisposition;
|
||||
|
||||
/**
|
||||
* Latest value reported of IME window visibility flags.
|
||||
*/
|
||||
@ImeWindowVisibility
|
||||
private int mImeWindowVisibility;
|
||||
|
||||
private Object mLock = new Object();
|
||||
@GuardedBy("mLock")
|
||||
private boolean mNotifyUserActionSent;
|
||||
@@ -1228,14 +1210,8 @@ public class InputMethodService extends AbstractInputMethodService {
|
||||
mImeSurfaceRemoverRunnable = null;
|
||||
}
|
||||
|
||||
private void setImeWindowStatus(@ImeWindowVisibility int vis,
|
||||
@BackDispositionMode int backDisposition) {
|
||||
if (vis == mImeWindowVisibility && backDisposition == mBackDisposition) {
|
||||
return;
|
||||
}
|
||||
mImeWindowVisibility = Preconditions.checkFlagsArgument(vis, IME_ACTIVE | IME_VISIBLE);
|
||||
mBackDisposition = backDisposition;
|
||||
mPrivOps.setImeWindowStatusAsync(mImeWindowVisibility, mBackDisposition);
|
||||
private void setImeWindowStatus(int visibilityFlags, int backDisposition) {
|
||||
mPrivOps.setImeWindowStatusAsync(visibilityFlags, backDisposition);
|
||||
}
|
||||
|
||||
/** Set region of the keyboard to be avoided from back gesture */
|
||||
@@ -1909,11 +1885,15 @@ public class InputMethodService extends AbstractInputMethodService {
|
||||
* @param disposition disposition mode to be set
|
||||
*/
|
||||
public void setBackDisposition(@BackDispositionMode int disposition) {
|
||||
if (disposition < BACK_DISPOSITION_MIN || disposition > BACK_DISPOSITION_MAX) {
|
||||
if (disposition == mBackDisposition) {
|
||||
return;
|
||||
}
|
||||
if (disposition > BACK_DISPOSITION_MAX || disposition < BACK_DISPOSITION_MIN) {
|
||||
Log.e(TAG, "Invalid back disposition value (" + disposition + ") specified.");
|
||||
return;
|
||||
}
|
||||
setImeWindowStatus(mImeWindowVisibility, disposition);
|
||||
mBackDisposition = disposition;
|
||||
setImeWindowStatus(mapToImeWindowStatus(), mBackDisposition);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2887,8 +2867,14 @@ public class InputMethodService extends AbstractInputMethodService {
|
||||
Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "IMS.showWindow");
|
||||
mDecorViewWasVisible = mDecorViewVisible;
|
||||
mInShowWindow = true;
|
||||
final int previousImeWindowStatus =
|
||||
(mDecorViewVisible ? IME_ACTIVE : 0) | (isInputViewShown()
|
||||
? (!mWindowVisible ? IME_INVISIBLE : IME_VISIBLE) : 0);
|
||||
startViews(prepareWindow(showInput));
|
||||
setImeWindowStatus(mapToImeWindowStatus(), mBackDisposition);
|
||||
final int nextImeWindowStatus = mapToImeWindowStatus();
|
||||
if (previousImeWindowStatus != nextImeWindowStatus) {
|
||||
setImeWindowStatus(nextImeWindowStatus, mBackDisposition);
|
||||
}
|
||||
|
||||
mNavigationBarController.onWindowShown();
|
||||
// compute visibility
|
||||
@@ -4099,9 +4085,9 @@ public class InputMethodService extends AbstractInputMethodService {
|
||||
};
|
||||
}
|
||||
|
||||
@ImeWindowVisibility
|
||||
private int mapToImeWindowStatus() {
|
||||
return IME_ACTIVE | (mDecorViewVisible ? IME_VISIBLE : 0);
|
||||
return IME_ACTIVE
|
||||
| (isInputViewShown() ? IME_VISIBLE : 0);
|
||||
}
|
||||
|
||||
private boolean isAutomotive() {
|
||||
|
||||
@@ -20,7 +20,6 @@ import android.annotation.AnyThread;
|
||||
import android.annotation.DrawableRes;
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.inputmethodservice.InputMethodService;
|
||||
import android.net.Uri;
|
||||
import android.os.IBinder;
|
||||
import android.os.RemoteException;
|
||||
@@ -106,10 +105,14 @@ public final class InputMethodPrivilegedOperations {
|
||||
*
|
||||
* @param vis visibility flags
|
||||
* @param backDisposition disposition flags
|
||||
* @see android.inputmethodservice.InputMethodService#IME_ACTIVE
|
||||
* @see android.inputmethodservice.InputMethodService#IME_VISIBLE
|
||||
* @see android.inputmethodservice.InputMethodService#IME_INVISIBLE
|
||||
* @see android.inputmethodservice.InputMethodService#BACK_DISPOSITION_DEFAULT
|
||||
* @see android.inputmethodservice.InputMethodService#BACK_DISPOSITION_ADJUST_NOTHING
|
||||
*/
|
||||
@AnyThread
|
||||
public void setImeWindowStatusAsync(@InputMethodService.ImeWindowVisibility int vis,
|
||||
@InputMethodService.BackDispositionMode int backDisposition) {
|
||||
public void setImeWindowStatusAsync(int vis, int backDisposition) {
|
||||
final IInputMethodPrivilegedOperations ops = mOps.getAndWarnIfNull();
|
||||
if (ops == null) {
|
||||
return;
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package com.android.internal.statusbar;
|
||||
|
||||
import android.inputmethodservice.InputMethodService;
|
||||
import android.os.IBinder;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
@@ -32,9 +31,7 @@ public final class RegisterStatusBarResult implements Parcelable {
|
||||
public final int mDisabledFlags1; // switch[0]
|
||||
public final int mAppearance; // switch[1]
|
||||
public final AppearanceRegion[] mAppearanceRegions; // switch[2]
|
||||
@InputMethodService.ImeWindowVisibility
|
||||
public final int mImeWindowVis; // switch[3]
|
||||
@InputMethodService.BackDispositionMode
|
||||
public final int mImeBackDisposition; // switch[4]
|
||||
public final boolean mShowImeSwitcher; // switch[5]
|
||||
public final int mDisabledFlags2; // switch[6]
|
||||
@@ -47,12 +44,10 @@ public final class RegisterStatusBarResult implements Parcelable {
|
||||
public final LetterboxDetails[] mLetterboxDetails;
|
||||
|
||||
public RegisterStatusBarResult(ArrayMap<String, StatusBarIcon> icons, int disabledFlags1,
|
||||
int appearance, AppearanceRegion[] appearanceRegions,
|
||||
@InputMethodService.ImeWindowVisibility int imeWindowVis,
|
||||
@InputMethodService.BackDispositionMode int imeBackDisposition, boolean showImeSwitcher,
|
||||
int disabledFlags2, IBinder imeToken, boolean navbarColorManagedByIme, int behavior,
|
||||
int requestedVisibleTypes, String packageName, int transientBarTypes,
|
||||
LetterboxDetails[] letterboxDetails) {
|
||||
int appearance, AppearanceRegion[] appearanceRegions, int imeWindowVis,
|
||||
int imeBackDisposition, boolean showImeSwitcher, int disabledFlags2, IBinder imeToken,
|
||||
boolean navbarColorManagedByIme, int behavior, int requestedVisibleTypes,
|
||||
String packageName, int transientBarTypes, LetterboxDetails[] letterboxDetails) {
|
||||
mIcons = new ArrayMap<>(icons);
|
||||
mDisabledFlags1 = disabledFlags1;
|
||||
mAppearance = appearance;
|
||||
|
||||
@@ -104,8 +104,7 @@ public class Utilities {
|
||||
* @return updated set of flags from InputMethodService based off {@param oldHints}
|
||||
* Leaves original hints unmodified
|
||||
*/
|
||||
public static int calculateBackDispositionHints(int oldHints,
|
||||
@InputMethodService.BackDispositionMode int backDisposition,
|
||||
public static int calculateBackDispositionHints(int oldHints, int backDisposition,
|
||||
boolean imeShown, boolean showImeSwitcher) {
|
||||
int hints = oldHints;
|
||||
switch (backDisposition) {
|
||||
|
||||
@@ -462,7 +462,7 @@ public final class NavBarHelper implements
|
||||
* @return Whether the IME is shown on top of the screen given the {@code vis} flag of
|
||||
* {@link InputMethodService} and the keyguard states.
|
||||
*/
|
||||
public boolean isImeShown(@InputMethodService.ImeWindowVisibility int vis) {
|
||||
public boolean isImeShown(int vis) {
|
||||
View shadeWindowView = mNotificationShadeWindowController.getWindowRootView();
|
||||
boolean isKeyguardShowing = mKeyguardStateController.isShowing();
|
||||
boolean imeVisibleOnShade = shadeWindowView != null && shadeWindowView.isAttachedToWindow()
|
||||
|
||||
@@ -66,7 +66,6 @@ import android.graphics.Point;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
import android.graphics.Region;
|
||||
import android.inputmethodservice.InputMethodService;
|
||||
import android.os.Binder;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
@@ -1048,9 +1047,8 @@ public class NavigationBar extends ViewController<NavigationBarView> implements
|
||||
// ----- CommandQueue Callbacks -----
|
||||
|
||||
@Override
|
||||
public void setImeWindowStatus(int displayId, IBinder token,
|
||||
@InputMethodService.ImeWindowVisibility int vis,
|
||||
@InputMethodService.BackDispositionMode int backDisposition, boolean showImeSwitcher) {
|
||||
public void setImeWindowStatus(int displayId, IBinder token, int vis, int backDisposition,
|
||||
boolean showImeSwitcher) {
|
||||
if (displayId != mDisplayId) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -338,9 +338,8 @@ public class TaskbarDelegate implements CommandQueue.Callbacks,
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setImeWindowStatus(int displayId, IBinder token,
|
||||
@InputMethodService.ImeWindowVisibility int vis,
|
||||
@InputMethodService.BackDispositionMode int backDisposition, boolean showImeSwitcher) {
|
||||
public void setImeWindowStatus(int displayId, IBinder token, int vis, int backDisposition,
|
||||
boolean showImeSwitcher) {
|
||||
boolean imeShown = mNavBarHelper.isImeShown(vis);
|
||||
if (!imeShown) {
|
||||
// Count imperceptible changes as visible so we transition taskbar out quickly.
|
||||
|
||||
@@ -19,6 +19,7 @@ package com.android.systemui.statusbar;
|
||||
import static android.app.StatusBarManager.DISABLE2_NONE;
|
||||
import static android.app.StatusBarManager.DISABLE_NONE;
|
||||
import static android.inputmethodservice.InputMethodService.BACK_DISPOSITION_DEFAULT;
|
||||
import static android.inputmethodservice.InputMethodService.IME_INVISIBLE;
|
||||
import static android.view.Display.INVALID_DISPLAY;
|
||||
|
||||
import android.annotation.Nullable;
|
||||
@@ -36,7 +37,7 @@ import android.hardware.biometrics.IBiometricContextListener;
|
||||
import android.hardware.biometrics.IBiometricSysuiReceiver;
|
||||
import android.hardware.biometrics.PromptInfo;
|
||||
import android.hardware.fingerprint.IUdfpsRefreshRateRequestCallback;
|
||||
import android.inputmethodservice.InputMethodService;
|
||||
import android.inputmethodservice.InputMethodService.BackDispositionMode;
|
||||
import android.media.INearbyMediaDevicesProvider;
|
||||
import android.media.MediaRoute2Info;
|
||||
import android.os.Binder;
|
||||
@@ -225,10 +226,8 @@ public class CommandQueue extends IStatusBar.Stub implements
|
||||
* @param backDisposition Disposition mode of back button. It should be one of below flags:
|
||||
* @param showImeSwitcher {@code true} to show IME switch button.
|
||||
*/
|
||||
default void setImeWindowStatus(int displayId, IBinder token,
|
||||
@InputMethodService.ImeWindowVisibility int vis,
|
||||
@InputMethodService.BackDispositionMode int backDisposition,
|
||||
boolean showImeSwitcher) { }
|
||||
default void setImeWindowStatus(int displayId, IBinder token, int vis,
|
||||
@BackDispositionMode int backDisposition, boolean showImeSwitcher) { }
|
||||
default void showRecentApps(boolean triggeredFromAltTab) { }
|
||||
default void hideRecentApps(boolean triggeredFromAltTab, boolean triggeredFromHomeKey) { }
|
||||
default void toggleTaskbar() { }
|
||||
@@ -679,9 +678,7 @@ public class CommandQueue extends IStatusBar.Stub implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setImeWindowStatus(int displayId, IBinder token,
|
||||
@InputMethodService.ImeWindowVisibility int vis,
|
||||
@InputMethodService.BackDispositionMode int backDisposition,
|
||||
public void setImeWindowStatus(int displayId, IBinder token, int vis, int backDisposition,
|
||||
boolean showImeSwitcher) {
|
||||
synchronized (mLock) {
|
||||
mHandler.removeMessages(MSG_SHOW_IME_BUTTON);
|
||||
@@ -1095,9 +1092,7 @@ public class CommandQueue extends IStatusBar.Stub implements
|
||||
}
|
||||
}
|
||||
|
||||
private void handleShowImeButton(int displayId, IBinder token,
|
||||
@InputMethodService.ImeWindowVisibility int vis,
|
||||
@InputMethodService.BackDispositionMode int backDisposition,
|
||||
private void handleShowImeButton(int displayId, IBinder token, int vis, int backDisposition,
|
||||
boolean showImeSwitcher) {
|
||||
if (displayId == INVALID_DISPLAY) return;
|
||||
|
||||
@@ -1117,7 +1112,7 @@ public class CommandQueue extends IStatusBar.Stub implements
|
||||
private void sendImeInvisibleStatusForPrevNavBar() {
|
||||
for (int i = 0; i < mCallbacks.size(); i++) {
|
||||
mCallbacks.get(i).setImeWindowStatus(mLastUpdatedImeDisplayId,
|
||||
null /* token */, 0 /* vis */, BACK_DISPOSITION_DEFAULT,
|
||||
null /* token */, IME_INVISIBLE, BACK_DISPOSITION_DEFAULT,
|
||||
false /* showImeSwitcher */);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -334,10 +334,8 @@ public final class WMShell implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setImeWindowStatus(int displayId, IBinder token,
|
||||
@InputMethodService.ImeWindowVisibility int vis,
|
||||
@InputMethodService.BackDispositionMode int backDisposition,
|
||||
boolean showImeSwitcher) {
|
||||
public void setImeWindowStatus(int displayId, IBinder token, int vis,
|
||||
int backDisposition, boolean showImeSwitcher) {
|
||||
if (displayId == mDisplayTracker.getDefaultDisplayId()
|
||||
&& (vis & InputMethodService.IME_VISIBLE) != 0) {
|
||||
oneHanded.stopOneHanded(
|
||||
|
||||
@@ -20,6 +20,7 @@ import static android.app.StatusBarManager.NAVIGATION_HINT_BACK_ALT;
|
||||
import static android.app.StatusBarManager.NAVIGATION_HINT_IME_SHOWN;
|
||||
import static android.app.StatusBarManager.NAVIGATION_HINT_IME_SWITCHER_SHOWN;
|
||||
import static android.inputmethodservice.InputMethodService.BACK_DISPOSITION_DEFAULT;
|
||||
import static android.inputmethodservice.InputMethodService.IME_INVISIBLE;
|
||||
import static android.inputmethodservice.InputMethodService.IME_VISIBLE;
|
||||
import static android.view.Display.DEFAULT_DISPLAY;
|
||||
import static android.view.DisplayAdjustments.DEFAULT_DISPLAY_ADJUSTMENTS;
|
||||
@@ -363,7 +364,7 @@ public class NavigationBarTest extends SysuiTestCase {
|
||||
externalNavBar.setImeWindowStatus(EXTERNAL_DISPLAY_ID, null, IME_VISIBLE,
|
||||
BACK_DISPOSITION_DEFAULT, true);
|
||||
defaultNavBar.setImeWindowStatus(
|
||||
DEFAULT_DISPLAY, null, 0 /* vis */, BACK_DISPOSITION_DEFAULT, false);
|
||||
DEFAULT_DISPLAY, null, IME_INVISIBLE, BACK_DISPOSITION_DEFAULT, false);
|
||||
// Verify IME window state will be updated in external NavBar & default NavBar state reset.
|
||||
assertEquals(NAVIGATION_HINT_BACK_ALT | NAVIGATION_HINT_IME_SHOWN
|
||||
| NAVIGATION_HINT_IME_SWITCHER_SHOWN,
|
||||
|
||||
@@ -16,6 +16,7 @@ package com.android.systemui.statusbar;
|
||||
|
||||
import static android.hardware.biometrics.BiometricAuthenticator.TYPE_FACE;
|
||||
import static android.inputmethodservice.InputMethodService.BACK_DISPOSITION_DEFAULT;
|
||||
import static android.inputmethodservice.InputMethodService.IME_INVISIBLE;
|
||||
import static android.view.Display.DEFAULT_DISPLAY;
|
||||
import static android.view.WindowInsetsController.BEHAVIOR_DEFAULT;
|
||||
|
||||
@@ -200,7 +201,7 @@ public class CommandQueueTest extends SysuiTestCase {
|
||||
|
||||
mCommandQueue.setImeWindowStatus(SECONDARY_DISPLAY, null, 1, 2, true);
|
||||
waitForIdleSync();
|
||||
verify(mCallbacks).setImeWindowStatus(eq(DEFAULT_DISPLAY), eq(null), eq(0),
|
||||
verify(mCallbacks).setImeWindowStatus(eq(DEFAULT_DISPLAY), eq(null), eq(IME_INVISIBLE),
|
||||
eq(BACK_DISPOSITION_DEFAULT), eq(false));
|
||||
verify(mCallbacks).setImeWindowStatus(
|
||||
eq(SECONDARY_DISPLAY), eq(null), eq(1), eq(2), eq(true));
|
||||
|
||||
@@ -352,7 +352,6 @@ final class InputMethodBindingController {
|
||||
clearCurMethodAndSessions();
|
||||
mService.clearInputShownLocked();
|
||||
mService.unbindCurrentClientLocked(UnbindReason.DISCONNECT_IME);
|
||||
mService.resetSystemUiLocked();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -633,9 +633,8 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
|
||||
private InputMethodSubtype mCurrentSubtype;
|
||||
|
||||
/**
|
||||
* {@code true} if the IME has not been mostly hidden via {@link android.view.InsetsController}.
|
||||
* {@code true} if the IME has not been mostly hidden via {@link android.view.InsetsController}
|
||||
*/
|
||||
@GuardedBy("ImfLock.class")
|
||||
private boolean mCurPerceptible;
|
||||
|
||||
/**
|
||||
@@ -749,26 +748,33 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
|
||||
SparseArray<AccessibilitySessionState> mEnabledAccessibilitySessions = new SparseArray<>();
|
||||
|
||||
/**
|
||||
* {@code true} if the device is currently interactive with the user, initially true.
|
||||
*
|
||||
* @see #handleSetInteractive
|
||||
* True if the device is currently interactive with user. The value is true initially.
|
||||
*/
|
||||
@GuardedBy("ImfLock.class")
|
||||
boolean mIsInteractive = true;
|
||||
|
||||
@GuardedBy("ImfLock.class")
|
||||
@InputMethodService.BackDispositionMode
|
||||
int mBackDisposition = InputMethodService.BACK_DISPOSITION_DEFAULT;
|
||||
|
||||
/**
|
||||
* The {@link InputMethodService.ImeWindowVisibility} of the currently bound IME,
|
||||
* or {@code 0} if no IME is bound.
|
||||
* A set of status bits regarding the active IME.
|
||||
*
|
||||
* <p><em>Do not update this value outside of {@link #setImeWindowStatus(IBinder, int, int)} and
|
||||
* <p>This value is a combination of following two bits:</p>
|
||||
* <dl>
|
||||
* <dt>{@link InputMethodService#IME_ACTIVE}</dt>
|
||||
* <dd>
|
||||
* If this bit is ON, connected IME is ready to accept touch/key events.
|
||||
* </dd>
|
||||
* <dt>{@link InputMethodService#IME_VISIBLE}</dt>
|
||||
* <dd>
|
||||
* If this bit is ON, some of IME view, e.g. software input, candidate view, is visible.
|
||||
* </dd>
|
||||
* <dt>{@link InputMethodService#IME_INVISIBLE}</dt>
|
||||
* <dd> If this bit is ON, IME is ready with views from last EditorInfo but is
|
||||
* currently invisible.
|
||||
* </dd>
|
||||
* </dl>
|
||||
* <em>Do not update this value outside of {@link #setImeWindowStatus(IBinder, int, int)} and
|
||||
* {@link InputMethodBindingController#unbindCurrentMethod()}.</em>
|
||||
*/
|
||||
@GuardedBy("ImfLock.class")
|
||||
@InputMethodService.ImeWindowVisibility
|
||||
int mImeWindowVis;
|
||||
|
||||
private LocaleList mLastSystemLocales;
|
||||
@@ -1529,6 +1535,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
|
||||
// Uh oh, current input method is no longer around!
|
||||
// Pick another one...
|
||||
Slog.i(TAG, "Current input method removed: " + curInputMethodId);
|
||||
updateSystemUiLocked(0 /* vis */, mBackDisposition);
|
||||
if (!chooseNewDefaultIMELocked()) {
|
||||
changed = true;
|
||||
curIm = null;
|
||||
@@ -2931,6 +2938,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
|
||||
sessionState.mSession.finishSession();
|
||||
} catch (RemoteException e) {
|
||||
Slog.w(TAG, "Session failed to close due to remote exception", e);
|
||||
updateSystemUiLocked(0 /* vis */, mBackDisposition);
|
||||
}
|
||||
sessionState.mSession = null;
|
||||
}
|
||||
@@ -3040,8 +3048,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
|
||||
}
|
||||
|
||||
@GuardedBy("ImfLock.class")
|
||||
private boolean shouldShowImeSwitcherLocked(
|
||||
@InputMethodService.ImeWindowVisibility int visibility) {
|
||||
private boolean shouldShowImeSwitcherLocked(int visibility) {
|
||||
if (!mShowOngoingImeSwitcherForPhones) return false;
|
||||
// When the IME switcher dialog is shown, the IME switcher button should be hidden.
|
||||
if (mMenuController.getSwitchingDialogLocked() != null) return false;
|
||||
@@ -3053,7 +3060,8 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
|
||||
&& mWindowManagerInternal.isKeyguardSecure(mSettings.getCurrentUserId())) {
|
||||
return false;
|
||||
}
|
||||
if ((visibility & InputMethodService.IME_ACTIVE) == 0) {
|
||||
if ((visibility & InputMethodService.IME_ACTIVE) == 0
|
||||
|| (visibility & InputMethodService.IME_INVISIBLE) != 0) {
|
||||
return false;
|
||||
}
|
||||
if (mWindowManagerInternal.isHardKeyboardAvailable()) {
|
||||
@@ -3112,9 +3120,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
|
||||
|
||||
@BinderThread
|
||||
@SuppressWarnings("deprecation")
|
||||
private void setImeWindowStatus(@NonNull IBinder token,
|
||||
@InputMethodService.ImeWindowVisibility int vis,
|
||||
@InputMethodService.BackDispositionMode int backDisposition) {
|
||||
private void setImeWindowStatus(@NonNull IBinder token, int vis, int backDisposition) {
|
||||
final int topFocusedDisplayId = mWindowManagerInternal.getTopFocusedDisplayId();
|
||||
|
||||
synchronized (ImfLock.class) {
|
||||
@@ -3131,7 +3137,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
|
||||
}
|
||||
mImeWindowVis = vis;
|
||||
mBackDisposition = backDisposition;
|
||||
updateSystemUiLocked(mImeWindowVis, mBackDisposition);
|
||||
updateSystemUiLocked(vis, backDisposition);
|
||||
}
|
||||
|
||||
final boolean dismissImeOnBackKeyPressed;
|
||||
@@ -3166,46 +3172,37 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
|
||||
|
||||
private void updateImeWindowStatus(boolean disableImeIcon) {
|
||||
synchronized (ImfLock.class) {
|
||||
// TODO(b/285109020): disableImeIcon should be stored in a property like
|
||||
// mIsSwitcherIconDisabled, but it is currently not reliably cleared.
|
||||
updateSystemUiLocked(disableImeIcon ? 0 : mImeWindowVis, mBackDisposition);
|
||||
if (disableImeIcon) {
|
||||
updateSystemUiLocked(0, mBackDisposition);
|
||||
} else {
|
||||
updateSystemUiLocked();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@GuardedBy("ImfLock.class")
|
||||
void updateSystemUiLocked() {
|
||||
// This is only used by InputMethodMenuController to trigger the IME switcher icon
|
||||
// visibility, by having {@code shouldShowImeSwitcherLocked} called, which depends on the
|
||||
// visibility of the IME switcher dialog.
|
||||
updateSystemUiLocked(mImeWindowVis, mBackDisposition);
|
||||
}
|
||||
|
||||
// Caution! This method is called in this class. Handle multi-user carefully
|
||||
@GuardedBy("ImfLock.class")
|
||||
private void updateSystemUiLocked(@InputMethodService.ImeWindowVisibility int vis,
|
||||
@InputMethodService.BackDispositionMode int backDisposition) {
|
||||
private void updateSystemUiLocked(int vis, int backDisposition) {
|
||||
if (getCurTokenLocked() == null) {
|
||||
return;
|
||||
}
|
||||
if (DEBUG) {
|
||||
Slog.d(TAG, "IME window vis: " + vis
|
||||
+ " active: " + ((vis & InputMethodService.IME_ACTIVE) != 0)
|
||||
+ " visible: " + ((vis & InputMethodService.IME_VISIBLE) != 0)
|
||||
+ " backDisposition: " + backDisposition
|
||||
+ " isInteractive: " + mIsInteractive
|
||||
+ " curPerceptible: " + mCurPerceptible
|
||||
+ " active: " + (vis & InputMethodService.IME_ACTIVE)
|
||||
+ " inv: " + (vis & InputMethodService.IME_INVISIBLE)
|
||||
+ " displayId: " + mCurTokenDisplayId);
|
||||
}
|
||||
|
||||
// TODO: Move this clearing calling identity block to setImeWindowStatus after making sure
|
||||
// all updateSystemUi happens on system privilege.
|
||||
// all updateSystemUi happens on system privilege.
|
||||
final long ident = Binder.clearCallingIdentity();
|
||||
try {
|
||||
if (!mIsInteractive) {
|
||||
// When we are not interactive,
|
||||
// the visibility should be 0 (no IME icons should be shown).
|
||||
vis = 0;
|
||||
} else if (!mCurPerceptible) {
|
||||
if (!mCurPerceptible) {
|
||||
if ((vis & InputMethodService.IME_VISIBLE) != 0) {
|
||||
vis &= ~InputMethodService.IME_VISIBLE;
|
||||
vis |= InputMethodService.IME_VISIBLE_IMPERCEPTIBLE;
|
||||
@@ -3540,7 +3537,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
|
||||
return;
|
||||
}
|
||||
mCurPerceptible = perceptible;
|
||||
updateSystemUiLocked(mImeWindowVis, mBackDisposition);
|
||||
updateSystemUiLocked();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -5102,11 +5099,8 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
|
||||
|
||||
private void handleSetInteractive(final boolean interactive) {
|
||||
synchronized (ImfLock.class) {
|
||||
if (mIsInteractive == interactive) {
|
||||
return;
|
||||
}
|
||||
mIsInteractive = interactive;
|
||||
updateSystemUiLocked(mImeWindowVis, mBackDisposition);
|
||||
updateSystemUiLocked(interactive ? mImeWindowVis : 0, mBackDisposition);
|
||||
|
||||
// Inform the current client of the change in active status
|
||||
if (mCurClient == null || mCurClient.mClient == null) {
|
||||
@@ -6741,8 +6735,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
|
||||
|
||||
@BinderThread
|
||||
@Override
|
||||
public void setImeWindowStatusAsync(@InputMethodService.ImeWindowVisibility int vis,
|
||||
@InputMethodService.BackDispositionMode int backDisposition) {
|
||||
public void setImeWindowStatusAsync(int vis, int backDisposition) {
|
||||
mImms.setImeWindowStatus(mToken, vis, backDisposition);
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@ package com.android.server.statusbar;
|
||||
import android.annotation.Nullable;
|
||||
import android.app.ITransientNotificationCallback;
|
||||
import android.hardware.fingerprint.IUdfpsRefreshRateRequestCallback;
|
||||
import android.inputmethodservice.InputMethodService;
|
||||
import android.os.Bundle;
|
||||
import android.os.IBinder;
|
||||
import android.view.WindowInsets.Type.InsetsType;
|
||||
@@ -55,13 +54,13 @@ public interface StatusBarManagerInternal {
|
||||
* @param displayId The display to which the IME is bound to.
|
||||
* @param token The IME token.
|
||||
* @param vis Bit flags about the IME visibility.
|
||||
* (e.g. {@link android.inputmethodservice.InputMethodService#IME_ACTIVE})
|
||||
* @param backDisposition Bit flags about the IME back disposition.
|
||||
* (e.g. {@link android.inputmethodservice.InputMethodService#BACK_DISPOSITION_DEFAULT})
|
||||
* @param showImeSwitcher {@code true} when the IME switcher button should be shown.
|
||||
*/
|
||||
void setImeWindowStatus(int displayId, IBinder token,
|
||||
@InputMethodService.ImeWindowVisibility int vis,
|
||||
@InputMethodService.BackDispositionMode int backDisposition,
|
||||
boolean showImeSwitcher);
|
||||
void setImeWindowStatus(int displayId, IBinder token, int vis,
|
||||
int backDisposition, boolean showImeSwitcher);
|
||||
|
||||
/**
|
||||
* See {@link android.app.StatusBarManager#setIcon(String, int, int, String)}.
|
||||
|
||||
@@ -59,7 +59,6 @@ import android.hardware.biometrics.PromptInfo;
|
||||
import android.hardware.display.DisplayManager;
|
||||
import android.hardware.display.DisplayManager.DisplayListener;
|
||||
import android.hardware.fingerprint.IUdfpsRefreshRateRequestCallback;
|
||||
import android.inputmethodservice.InputMethodService;
|
||||
import android.media.INearbyMediaDevicesProvider;
|
||||
import android.media.MediaRoute2Info;
|
||||
import android.net.Uri;
|
||||
@@ -533,9 +532,7 @@ public class StatusBarManagerService extends IStatusBarService.Stub implements D
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setImeWindowStatus(int displayId, IBinder token,
|
||||
@InputMethodService.ImeWindowVisibility int vis,
|
||||
@InputMethodService.BackDispositionMode int backDisposition,
|
||||
public void setImeWindowStatus(int displayId, IBinder token, int vis, int backDisposition,
|
||||
boolean showImeSwitcher) {
|
||||
StatusBarManagerService.this.setImeWindowStatus(displayId, token, vis, backDisposition,
|
||||
showImeSwitcher);
|
||||
@@ -1267,14 +1264,12 @@ public class StatusBarManagerService extends IStatusBarService.Stub implements D
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setImeWindowStatus(int displayId, final IBinder token,
|
||||
@InputMethodService.ImeWindowVisibility final int vis,
|
||||
@InputMethodService.BackDispositionMode final int backDisposition,
|
||||
final boolean showImeSwitcher) {
|
||||
public void setImeWindowStatus(int displayId, final IBinder token, final int vis,
|
||||
final int backDisposition, final boolean showImeSwitcher) {
|
||||
enforceStatusBar();
|
||||
|
||||
if (SPEW) {
|
||||
Slog.d(TAG, "setImeWindowStatus vis=" + vis + " backDisposition=" + backDisposition);
|
||||
Slog.d(TAG, "swetImeWindowStatus vis=" + vis + " backDisposition=" + backDisposition);
|
||||
}
|
||||
|
||||
synchronized(mLock) {
|
||||
@@ -1337,9 +1332,7 @@ public class StatusBarManagerService extends IStatusBarService.Stub implements D
|
||||
private String mPackageName = "none";
|
||||
private int mDisabled1 = 0;
|
||||
private int mDisabled2 = 0;
|
||||
@InputMethodService.ImeWindowVisibility
|
||||
private int mImeWindowVis = 0;
|
||||
@InputMethodService.BackDispositionMode
|
||||
private int mImeBackDisposition = 0;
|
||||
private boolean mShowImeSwitcher = false;
|
||||
private IBinder mImeToken = null;
|
||||
@@ -1384,8 +1377,7 @@ public class StatusBarManagerService extends IStatusBarService.Stub implements D
|
||||
return mDisabled1 == disabled1 && mDisabled2 == disabled2;
|
||||
}
|
||||
|
||||
private void setImeWindowState(@InputMethodService.ImeWindowVisibility final int vis,
|
||||
@InputMethodService.BackDispositionMode final int backDisposition,
|
||||
private void setImeWindowState(final int vis, final int backDisposition,
|
||||
final boolean showImeSwitcher, final IBinder token) {
|
||||
mImeWindowVis = vis;
|
||||
mImeBackDisposition = backDisposition;
|
||||
|
||||
Reference in New Issue
Block a user