Loading core/java/android/view/IWindowManager.aidl +1 −4 Original line number Original line Diff line number Diff line Loading @@ -17,8 +17,6 @@ package android.view; package android.view; import com.android.internal.os.IResultReceiver; import com.android.internal.os.IResultReceiver; import com.android.internal.view.IInputContext; import com.android.internal.view.IInputMethodClient; import com.android.internal.policy.IKeyguardDismissCallback; import com.android.internal.policy.IKeyguardDismissCallback; import com.android.internal.policy.IShortcutService; import com.android.internal.policy.IShortcutService; Loading Loading @@ -71,8 +69,7 @@ interface IWindowManager boolean stopViewServer(); // Transaction #2 boolean stopViewServer(); // Transaction #2 boolean isViewServerRunning(); // Transaction #3 boolean isViewServerRunning(); // Transaction #3 IWindowSession openSession(in IWindowSessionCallback callback, in IInputMethodClient client, IWindowSession openSession(in IWindowSessionCallback callback); in IInputContext inputContext); void getInitialDisplaySize(int displayId, out Point size); void getInitialDisplaySize(int displayId, out Point size); void getBaseDisplaySize(int displayId, out Point size); void getBaseDisplaySize(int displayId, out Point size); Loading core/java/android/view/WindowManagerGlobal.java +6 −3 Original line number Original line Diff line number Diff line Loading @@ -196,7 +196,11 @@ public final class WindowManagerGlobal { synchronized (WindowManagerGlobal.class) { synchronized (WindowManagerGlobal.class) { if (sWindowSession == null) { if (sWindowSession == null) { try { try { InputMethodManager imm = InputMethodManager.getInstance(); if (InputMethodManager.ENABLE_LEGACY_EAGER_INITIALIZATION) { // Emulate the legacy behavior. The global instance of InputMethodManager // was instantiated here. InputMethodManager.getInstance(); } IWindowManager windowManager = getWindowManagerService(); IWindowManager windowManager = getWindowManagerService(); sWindowSession = windowManager.openSession( sWindowSession = windowManager.openSession( new IWindowSessionCallback.Stub() { new IWindowSessionCallback.Stub() { Loading @@ -204,8 +208,7 @@ public final class WindowManagerGlobal { public void onAnimatorScaleChanged(float scale) { public void onAnimatorScaleChanged(float scale) { ValueAnimator.setDurationScale(scale); ValueAnimator.setDurationScale(scale); } } }, }); imm.getClient(), imm.getInputContext()); } catch (RemoteException e) { } catch (RemoteException e) { throw e.rethrowFromSystemServer(); throw e.rethrowFromSystemServer(); } } Loading core/java/android/view/inputmethod/InputMethodManager.java +42 −2 Original line number Original line Diff line number Diff line Loading @@ -225,6 +225,44 @@ public final class InputMethodManager { static final String PENDING_EVENT_COUNTER = "aq:imm"; static final String PENDING_EVENT_COUNTER = "aq:imm"; /** * {@code true} if we want to instantiate {@link InputMethodManager} eagerly in * {@link android.view.WindowManagerGlobal#getWindowSession()}, which is often called in an * early stage of process startup, which is how Android has worked. * * <p>We still have this settings because we know there are possible compatibility concerns if * we stop doing so. Here are scenarios we know and there could be more scenarios we are not * aware of right know.</p> * * <ul> * <li>Apps that directly access {@link #sInstance} via reflection, which is currently * allowed because of {@link UnsupportedAppUsage} annotation. Currently * {@link android.view.WindowManagerGlobal#getWindowSession()} is likely to guarantee that * {@link #sInstance} is not {@code null} when such an app is accessing it, but removing * that code from {@link android.view.WindowManagerGlobal#getWindowSession()} can reveal * untested code paths in their apps, which probably happen in an early startup time of that * app.</li> * <li>Apps that directly access {@link #peekInstance()} via reflection, which is currently * allowed because of {@link UnsupportedAppUsage} annotation. Currently * {@link android.view.WindowManagerGlobal#getWindowSession()} is likely to guarantee that * {@link #peekInstance()} returns non-{@code null} object when such an app is calling * {@link #peekInstance()}, but removing that code from * {@link android.view.WindowManagerGlobal#getWindowSession()} can reveal untested code * paths in their apps, which probably happen in an early startup time of that app. The good * news is that unlike {@link #sInstance}'s case we can at least work around this scenario * by changing the semantics of {@link #peekInstance()}, which is currently defined as * "retrieve the global {@link InputMethodManager} instance, if it exists" to something that * always returns non-{@code null} {@link InputMethodManager}. However, introducing such an * workaround can also trigger different compatibility issues if {@link #peekInstance()} was * called before {@link android.view.WindowManagerGlobal#getWindowSession()} and it expected * {@link #peekInstance()} to return {@code null} as written in the JavaDoc.</li> * </ul> * * <p>TODO(Bug 116157766): Check if we can set {@code false} here then remove this settings.</p> * @hide */ public static final boolean ENABLE_LEGACY_EAGER_INITIALIZATION = true; @UnsupportedAppUsage @UnsupportedAppUsage static InputMethodManager sInstance; static InputMethodManager sInstance; Loading Loading @@ -651,8 +689,10 @@ public final class InputMethodManager { synchronized (InputMethodManager.class) { synchronized (InputMethodManager.class) { if (sInstance == null) { if (sInstance == null) { try { try { sInstance = new InputMethodManager(Looper.getMainLooper()); final InputMethodManager imm = new InputMethodManager(Looper.getMainLooper()); } catch (ServiceNotFoundException e) { imm.mService.addClient(imm.mClient, imm.mIInputContext); sInstance = imm; } catch (ServiceNotFoundException | RemoteException e) { throw new IllegalStateException(e); throw new IllegalStateException(e); } } } } Loading core/java/com/android/internal/view/IInputMethodManager.aidl +2 −0 Original line number Original line Diff line number Diff line Loading @@ -31,6 +31,8 @@ import com.android.internal.view.IInputMethodClient; * applications. * applications. */ */ interface IInputMethodManager { interface IInputMethodManager { void addClient(in IInputMethodClient client, in IInputContext inputContext); // TODO: Use ParceledListSlice instead // TODO: Use ParceledListSlice instead List<InputMethodInfo> getInputMethodList(); List<InputMethodInfo> getInputMethodList(); List<InputMethodInfo> getVrInputMethodList(); List<InputMethodInfo> getVrInputMethodList(); Loading services/core/java/com/android/server/inputmethod/InputMethodManagerInternal.java +0 −43 Original line number Original line Diff line number Diff line Loading @@ -18,44 +18,10 @@ package com.android.server.inputmethod; import android.content.ComponentName; import android.content.ComponentName; import com.android.internal.view.IInputContext; import com.android.internal.view.IInputMethodClient; /** /** * Input method manager local system service interface. * Input method manager local system service interface. */ */ public abstract class InputMethodManagerInternal { public abstract class InputMethodManagerInternal { /** * Called by the window manager service when a client process is being attached to the window * manager service. * * <p>The caller must not have WindowManagerService lock. This method internally acquires * InputMethodManagerService lock.</p> * * @param client {@link android.os.Binder} proxy that is associated with the singleton instance * of {@link android.view.inputmethod.InputMethodManager} that runs on the client * process * @param inputContext communication channel for the dummy * {@link android.view.inputmethod.InputConnection} * @param uid UID of the client process * @param pid PID of the client process */ public abstract void addClient(IInputMethodClient client, IInputContext inputContext, int uid, int pid); /** * Called by the window manager service when a client process is being attached to the window * manager service. * * <p>The caller must not have WindowManagerService lock. This method internally acquires * InputMethodManagerService lock.</p> * * @param client {@link android.os.Binder} proxy that is associated with the singleton instance * of {@link android.view.inputmethod.InputMethodManager} that runs on the client * process */ public abstract void removeClient(IInputMethodClient client); /** /** * Called by the power manager to tell the input method manager whether it * Called by the power manager to tell the input method manager whether it * should start watching for wake events. * should start watching for wake events. Loading @@ -77,15 +43,6 @@ public abstract class InputMethodManagerInternal { */ */ public static final InputMethodManagerInternal NOP = public static final InputMethodManagerInternal NOP = new InputMethodManagerInternal() { new InputMethodManagerInternal() { @Override public void addClient(IInputMethodClient client, IInputContext inputContext, int uid, int pid) { } @Override public void removeClient(IInputMethodClient client) { } @Override @Override public void setInteractive(boolean interactive) { public void setInteractive(boolean interactive) { } } Loading Loading
core/java/android/view/IWindowManager.aidl +1 −4 Original line number Original line Diff line number Diff line Loading @@ -17,8 +17,6 @@ package android.view; package android.view; import com.android.internal.os.IResultReceiver; import com.android.internal.os.IResultReceiver; import com.android.internal.view.IInputContext; import com.android.internal.view.IInputMethodClient; import com.android.internal.policy.IKeyguardDismissCallback; import com.android.internal.policy.IKeyguardDismissCallback; import com.android.internal.policy.IShortcutService; import com.android.internal.policy.IShortcutService; Loading Loading @@ -71,8 +69,7 @@ interface IWindowManager boolean stopViewServer(); // Transaction #2 boolean stopViewServer(); // Transaction #2 boolean isViewServerRunning(); // Transaction #3 boolean isViewServerRunning(); // Transaction #3 IWindowSession openSession(in IWindowSessionCallback callback, in IInputMethodClient client, IWindowSession openSession(in IWindowSessionCallback callback); in IInputContext inputContext); void getInitialDisplaySize(int displayId, out Point size); void getInitialDisplaySize(int displayId, out Point size); void getBaseDisplaySize(int displayId, out Point size); void getBaseDisplaySize(int displayId, out Point size); Loading
core/java/android/view/WindowManagerGlobal.java +6 −3 Original line number Original line Diff line number Diff line Loading @@ -196,7 +196,11 @@ public final class WindowManagerGlobal { synchronized (WindowManagerGlobal.class) { synchronized (WindowManagerGlobal.class) { if (sWindowSession == null) { if (sWindowSession == null) { try { try { InputMethodManager imm = InputMethodManager.getInstance(); if (InputMethodManager.ENABLE_LEGACY_EAGER_INITIALIZATION) { // Emulate the legacy behavior. The global instance of InputMethodManager // was instantiated here. InputMethodManager.getInstance(); } IWindowManager windowManager = getWindowManagerService(); IWindowManager windowManager = getWindowManagerService(); sWindowSession = windowManager.openSession( sWindowSession = windowManager.openSession( new IWindowSessionCallback.Stub() { new IWindowSessionCallback.Stub() { Loading @@ -204,8 +208,7 @@ public final class WindowManagerGlobal { public void onAnimatorScaleChanged(float scale) { public void onAnimatorScaleChanged(float scale) { ValueAnimator.setDurationScale(scale); ValueAnimator.setDurationScale(scale); } } }, }); imm.getClient(), imm.getInputContext()); } catch (RemoteException e) { } catch (RemoteException e) { throw e.rethrowFromSystemServer(); throw e.rethrowFromSystemServer(); } } Loading
core/java/android/view/inputmethod/InputMethodManager.java +42 −2 Original line number Original line Diff line number Diff line Loading @@ -225,6 +225,44 @@ public final class InputMethodManager { static final String PENDING_EVENT_COUNTER = "aq:imm"; static final String PENDING_EVENT_COUNTER = "aq:imm"; /** * {@code true} if we want to instantiate {@link InputMethodManager} eagerly in * {@link android.view.WindowManagerGlobal#getWindowSession()}, which is often called in an * early stage of process startup, which is how Android has worked. * * <p>We still have this settings because we know there are possible compatibility concerns if * we stop doing so. Here are scenarios we know and there could be more scenarios we are not * aware of right know.</p> * * <ul> * <li>Apps that directly access {@link #sInstance} via reflection, which is currently * allowed because of {@link UnsupportedAppUsage} annotation. Currently * {@link android.view.WindowManagerGlobal#getWindowSession()} is likely to guarantee that * {@link #sInstance} is not {@code null} when such an app is accessing it, but removing * that code from {@link android.view.WindowManagerGlobal#getWindowSession()} can reveal * untested code paths in their apps, which probably happen in an early startup time of that * app.</li> * <li>Apps that directly access {@link #peekInstance()} via reflection, which is currently * allowed because of {@link UnsupportedAppUsage} annotation. Currently * {@link android.view.WindowManagerGlobal#getWindowSession()} is likely to guarantee that * {@link #peekInstance()} returns non-{@code null} object when such an app is calling * {@link #peekInstance()}, but removing that code from * {@link android.view.WindowManagerGlobal#getWindowSession()} can reveal untested code * paths in their apps, which probably happen in an early startup time of that app. The good * news is that unlike {@link #sInstance}'s case we can at least work around this scenario * by changing the semantics of {@link #peekInstance()}, which is currently defined as * "retrieve the global {@link InputMethodManager} instance, if it exists" to something that * always returns non-{@code null} {@link InputMethodManager}. However, introducing such an * workaround can also trigger different compatibility issues if {@link #peekInstance()} was * called before {@link android.view.WindowManagerGlobal#getWindowSession()} and it expected * {@link #peekInstance()} to return {@code null} as written in the JavaDoc.</li> * </ul> * * <p>TODO(Bug 116157766): Check if we can set {@code false} here then remove this settings.</p> * @hide */ public static final boolean ENABLE_LEGACY_EAGER_INITIALIZATION = true; @UnsupportedAppUsage @UnsupportedAppUsage static InputMethodManager sInstance; static InputMethodManager sInstance; Loading Loading @@ -651,8 +689,10 @@ public final class InputMethodManager { synchronized (InputMethodManager.class) { synchronized (InputMethodManager.class) { if (sInstance == null) { if (sInstance == null) { try { try { sInstance = new InputMethodManager(Looper.getMainLooper()); final InputMethodManager imm = new InputMethodManager(Looper.getMainLooper()); } catch (ServiceNotFoundException e) { imm.mService.addClient(imm.mClient, imm.mIInputContext); sInstance = imm; } catch (ServiceNotFoundException | RemoteException e) { throw new IllegalStateException(e); throw new IllegalStateException(e); } } } } Loading
core/java/com/android/internal/view/IInputMethodManager.aidl +2 −0 Original line number Original line Diff line number Diff line Loading @@ -31,6 +31,8 @@ import com.android.internal.view.IInputMethodClient; * applications. * applications. */ */ interface IInputMethodManager { interface IInputMethodManager { void addClient(in IInputMethodClient client, in IInputContext inputContext); // TODO: Use ParceledListSlice instead // TODO: Use ParceledListSlice instead List<InputMethodInfo> getInputMethodList(); List<InputMethodInfo> getInputMethodList(); List<InputMethodInfo> getVrInputMethodList(); List<InputMethodInfo> getVrInputMethodList(); Loading
services/core/java/com/android/server/inputmethod/InputMethodManagerInternal.java +0 −43 Original line number Original line Diff line number Diff line Loading @@ -18,44 +18,10 @@ package com.android.server.inputmethod; import android.content.ComponentName; import android.content.ComponentName; import com.android.internal.view.IInputContext; import com.android.internal.view.IInputMethodClient; /** /** * Input method manager local system service interface. * Input method manager local system service interface. */ */ public abstract class InputMethodManagerInternal { public abstract class InputMethodManagerInternal { /** * Called by the window manager service when a client process is being attached to the window * manager service. * * <p>The caller must not have WindowManagerService lock. This method internally acquires * InputMethodManagerService lock.</p> * * @param client {@link android.os.Binder} proxy that is associated with the singleton instance * of {@link android.view.inputmethod.InputMethodManager} that runs on the client * process * @param inputContext communication channel for the dummy * {@link android.view.inputmethod.InputConnection} * @param uid UID of the client process * @param pid PID of the client process */ public abstract void addClient(IInputMethodClient client, IInputContext inputContext, int uid, int pid); /** * Called by the window manager service when a client process is being attached to the window * manager service. * * <p>The caller must not have WindowManagerService lock. This method internally acquires * InputMethodManagerService lock.</p> * * @param client {@link android.os.Binder} proxy that is associated with the singleton instance * of {@link android.view.inputmethod.InputMethodManager} that runs on the client * process */ public abstract void removeClient(IInputMethodClient client); /** /** * Called by the power manager to tell the input method manager whether it * Called by the power manager to tell the input method manager whether it * should start watching for wake events. * should start watching for wake events. Loading @@ -77,15 +43,6 @@ public abstract class InputMethodManagerInternal { */ */ public static final InputMethodManagerInternal NOP = public static final InputMethodManagerInternal NOP = new InputMethodManagerInternal() { new InputMethodManagerInternal() { @Override public void addClient(IInputMethodClient client, IInputContext inputContext, int uid, int pid) { } @Override public void removeClient(IInputMethodClient client) { } @Override @Override public void setInteractive(boolean interactive) { public void setInteractive(boolean interactive) { } } Loading