Loading core/java/android/view/WindowManagerInternal.java +32 −0 Original line number Diff line number Diff line Loading @@ -119,6 +119,13 @@ public abstract class WindowManagerInternal { public void onAppTransitionFinishedLocked(IBinder token) {} } /** * An interface to be notified about hardware keyboard status. */ public interface OnHardKeyboardStatusChangeListener { public void onHardKeyboardStatusChange(boolean available); } /** * Request that the window manager call * {@link DisplayManagerInternal#performTraversalInTransactionFromWindowManager} Loading Loading @@ -231,4 +238,29 @@ public abstract class WindowManagerInternal { * @param listener The listener to register. */ public abstract void registerAppTransitionListener(AppTransitionListener listener); /** * Retrieves a height of input method window. */ public abstract int getInputMethodWindowVisibleHeight(); /** * Saves last input method window for transition. * * Note that it is assumed that this method is called only by InputMethodManagerService. */ public abstract void saveLastInputMethodWindowForTransition(); /** * Returns true when the hardware keyboard is available. */ public abstract boolean isHardKeyboardAvailable(); /** * Sets the callback listener for hardware keyboard status changes. * * @param listener The listener to set. */ public abstract void setOnHardKeyboardStatusChangeListener( OnHardKeyboardStatusChangeListener listener); } services/core/java/com/android/server/InputMethodManagerService.java +21 −18 Original line number Diff line number Diff line Loading @@ -33,7 +33,6 @@ import com.android.internal.view.IInputMethodManager; import com.android.internal.view.IInputMethodSession; import com.android.internal.view.InputBindResult; import com.android.server.statusbar.StatusBarManagerService; import com.android.server.wm.WindowManagerService; import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; Loading Loading @@ -109,6 +108,7 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.view.WindowManager; import android.view.WindowManagerInternal; import android.view.inputmethod.EditorInfo; import android.view.inputmethod.InputBinding; import android.view.inputmethod.InputMethod; Loading Loading @@ -182,11 +182,11 @@ public class InputMethodManagerService extends IInputMethodManager.Stub final InputMethodSettings mSettings; final SettingsObserver mSettingsObserver; final IWindowManager mIWindowManager; final WindowManagerInternal mWindowManagerInternal; final HandlerCaller mCaller; final boolean mHasFeature; private InputMethodFileManager mFileManager; private final HardKeyboardListener mHardKeyboardListener; private final WindowManagerService mWindowManagerService; private final AppOpsManager mAppOpsManager; final InputBindResult mNoBinding = new InputBindResult(null, null, null, -1, -1); Loading Loading @@ -710,7 +710,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub } private class HardKeyboardListener implements WindowManagerService.OnHardKeyboardStatusChangeListener { implements WindowManagerInternal.OnHardKeyboardStatusChangeListener { @Override public void onHardKeyboardStatusChange(boolean available) { mHandler.sendMessage(mHandler.obtainMessage(MSG_HARD_KEYBOARD_SWITCH_CHANGED, Loading @@ -732,7 +732,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub } } public InputMethodManagerService(Context context, WindowManagerService windowManager) { public InputMethodManagerService(Context context) { mIPackageManager = AppGlobals.getPackageManager(); mContext = context; mRes = context.getResources(); Loading @@ -741,13 +741,13 @@ public class InputMethodManagerService extends IInputMethodManager.Stub mSettingsObserver = new SettingsObserver(mHandler); mIWindowManager = IWindowManager.Stub.asInterface( ServiceManager.getService(Context.WINDOW_SERVICE)); mWindowManagerInternal = LocalServices.getService(WindowManagerInternal.class); mCaller = new HandlerCaller(context, null, new HandlerCaller.Callback() { @Override public void executeMessage(Message msg) { handleMessage(msg); } }, true /*asyncHandler*/); mWindowManagerService = windowManager; mAppOpsManager = (AppOpsManager) mContext.getSystemService(Context.APP_OPS_SERVICE); mHardKeyboardListener = new HardKeyboardListener(); mHasFeature = context.getPackageManager().hasSystemFeature( Loading Loading @@ -1045,7 +1045,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub mShowOngoingImeSwitcherForPhones = mRes.getBoolean( com.android.internal.R.bool.show_ongoing_ime_switcher); if (mShowOngoingImeSwitcherForPhones) { mWindowManagerService.setOnHardKeyboardStatusChangeListener( mWindowManagerInternal.setOnHardKeyboardStatusChangeListener( mHardKeyboardListener); } buildInputMethodListLocked(mMethodList, mMethodMap, Loading Loading @@ -1507,7 +1507,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub if (DEBUG) Slog.v(TAG, "Removing window token: " + mCurToken); if ((mImeWindowVis & InputMethodService.IME_ACTIVE) != 0 && savePosition) { // The current IME is shown. Hence an IME switch (transition) is happening. mWindowManagerService.saveLastInputMethodWindowForTransition(); mWindowManagerInternal.saveLastInputMethodWindowForTransition(); } mIWindowManager.removeWindowToken(mCurToken); } catch (RemoteException e) { Loading Loading @@ -1641,7 +1641,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub if (mSwitchingDialog != null) return false; if (isScreenLocked()) return false; if ((visibility & InputMethodService.IME_ACTIVE) == 0) return false; if (mWindowManagerService.isHardKeyboardAvailable()) { if (mWindowManagerInternal.isHardKeyboardAvailable()) { // When physical keyboard is attached, we show the ime switcher (or notification if // NavBar is not available) because SHOW_IME_WITH_HARD_KEYBOARD settings currently // exists in the IME switcher dialog. Might be OK to remove this condition once Loading Loading @@ -1753,8 +1753,9 @@ public class InputMethodManagerService extends IInputMethodManager.Stub mImeSwitcherNotification.setContentTitle(title) .setContentText(summary) .setContentIntent(mImeSwitchPendingIntent); try { if ((mNotificationManager != null) && !mWindowManagerService.hasNavigationBar()) { && !mIWindowManager.hasNavigationBar()) { if (DEBUG) { Slog.d(TAG, "--- show notification: label = " + summary); } Loading @@ -1763,6 +1764,8 @@ public class InputMethodManagerService extends IInputMethodManager.Stub mImeSwitcherNotification.build(), UserHandle.ALL); mNotificationShown = true; } } catch (RemoteException e) { } } else { if (mNotificationShown && mNotificationManager != null) { if (DEBUG) { Loading Loading @@ -2527,7 +2530,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub @Override public int getInputMethodWindowVisibleHeight() { return mWindowManagerService.getInputMethodWindowVisibleHeight(); return mWindowManagerInternal.getInputMethodWindowVisibleHeight(); } @Override Loading Loading @@ -3041,7 +3044,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub mSwitchingDialogTitleView = tv; mSwitchingDialogTitleView .findViewById(com.android.internal.R.id.hard_keyboard_section) .setVisibility(mWindowManagerService.isHardKeyboardAvailable() .setVisibility(mWindowManagerInternal.isHardKeyboardAvailable() ? View.VISIBLE : View.GONE); final Switch hardKeySwitch = (Switch) mSwitchingDialogTitleView.findViewById( com.android.internal.R.id.hard_keyboard_switch); Loading services/core/java/com/android/server/wm/WindowManagerService.java +36 −36 Original line number Diff line number Diff line Loading @@ -552,7 +552,7 @@ public class WindowManagerService extends IWindowManager.Stub boolean mHardKeyboardAvailable; boolean mShowImeWithHardKeyboard; OnHardKeyboardStatusChangeListener mHardKeyboardStatusChangeListener; WindowManagerInternal.OnHardKeyboardStatusChangeListener mHardKeyboardStatusChangeListener; SettingsObserver mSettingsObserver; private final class SettingsObserver extends ContentObserver { Loading Loading @@ -6808,12 +6808,6 @@ public class WindowManagerService extends IWindowManager.Stub mPolicy.adjustConfigurationLw(config, keyboardPresence, navigationPresence); } public boolean isHardKeyboardAvailable() { synchronized (mWindowMap) { return mHardKeyboardAvailable; } } public void updateShowImeWithHardKeyboard() { synchronized (mWindowMap) { final boolean showImeWithHardKeyboard = Settings.Secure.getIntForUser( Loading @@ -6826,16 +6820,9 @@ public class WindowManagerService extends IWindowManager.Stub } } public void setOnHardKeyboardStatusChangeListener( OnHardKeyboardStatusChangeListener listener) { synchronized (mWindowMap) { mHardKeyboardStatusChangeListener = listener; } } void notifyHardKeyboardStatusChange() { final boolean available; final OnHardKeyboardStatusChangeListener listener; final WindowManagerInternal.OnHardKeyboardStatusChangeListener listener; synchronized (mWindowMap) { listener = mHardKeyboardStatusChangeListener; available = mHardKeyboardAvailable; Loading Loading @@ -10431,23 +10418,6 @@ public class WindowManagerService extends IWindowManager.Stub } } // It is assumed that this method is called only by InputMethodManagerService. public void saveLastInputMethodWindowForTransition() { synchronized (mWindowMap) { // TODO(multidisplay): Pass in the displayID. DisplayContent displayContent = getDefaultDisplayContentLocked(); if (mInputMethodWindow != null) { mPolicy.setLastInputMethodWindowLw(mInputMethodWindow, mInputMethodTarget); } } } public int getInputMethodWindowVisibleHeight() { synchronized (mWindowMap) { return mPolicy.getInputMethodWindowVisibleHeightLw(); } } @Override public boolean hasNavigationBar() { return mPolicy.hasNavigationBar(); Loading Loading @@ -11037,10 +11007,6 @@ public class WindowManagerService extends IWindowManager.Stub synchronized (mWindowMap) { } } public interface OnHardKeyboardStatusChangeListener { public void onHardKeyboardStatusChange(boolean available); } void debugLayoutRepeats(final String msg, int pendingLayoutChanges) { if (mLayoutRepeatCount >= LAYOUT_REPEAT_THRESHOLD) { Slog.v(TAG, "Layouts looping: " + msg + ", mPendingLayoutChanges = 0x" + Loading Loading @@ -11348,5 +11314,39 @@ public class WindowManagerService extends IWindowManager.Stub mAppTransition.registerListenerLocked(listener); } } @Override public int getInputMethodWindowVisibleHeight() { synchronized (mWindowMap) { return mPolicy.getInputMethodWindowVisibleHeightLw(); } } @Override public void saveLastInputMethodWindowForTransition() { synchronized (mWindowMap) { // TODO(multidisplay): Pass in the displayID. DisplayContent displayContent = getDefaultDisplayContentLocked(); if (mInputMethodWindow != null) { mPolicy.setLastInputMethodWindowLw(mInputMethodWindow, mInputMethodTarget); } } } @Override public boolean isHardKeyboardAvailable() { synchronized (mWindowMap) { return mHardKeyboardAvailable; } } @Override public void setOnHardKeyboardStatusChangeListener( OnHardKeyboardStatusChangeListener listener) { synchronized (mWindowMap) { mHardKeyboardStatusChangeListener = listener; } } } } services/java/com/android/server/SystemServer.java +1 −1 Original line number Diff line number Diff line Loading @@ -546,7 +546,7 @@ public final class SystemServer { if (mFactoryTestMode != FactoryTest.FACTORY_TEST_LOW_LEVEL) { try { Slog.i(TAG, "Input Method Service"); imm = new InputMethodManagerService(context, wm); imm = new InputMethodManagerService(context); ServiceManager.addService(Context.INPUT_METHOD_SERVICE, imm); } catch (Throwable e) { reportWtf("starting Input Manager Service", e); Loading Loading
core/java/android/view/WindowManagerInternal.java +32 −0 Original line number Diff line number Diff line Loading @@ -119,6 +119,13 @@ public abstract class WindowManagerInternal { public void onAppTransitionFinishedLocked(IBinder token) {} } /** * An interface to be notified about hardware keyboard status. */ public interface OnHardKeyboardStatusChangeListener { public void onHardKeyboardStatusChange(boolean available); } /** * Request that the window manager call * {@link DisplayManagerInternal#performTraversalInTransactionFromWindowManager} Loading Loading @@ -231,4 +238,29 @@ public abstract class WindowManagerInternal { * @param listener The listener to register. */ public abstract void registerAppTransitionListener(AppTransitionListener listener); /** * Retrieves a height of input method window. */ public abstract int getInputMethodWindowVisibleHeight(); /** * Saves last input method window for transition. * * Note that it is assumed that this method is called only by InputMethodManagerService. */ public abstract void saveLastInputMethodWindowForTransition(); /** * Returns true when the hardware keyboard is available. */ public abstract boolean isHardKeyboardAvailable(); /** * Sets the callback listener for hardware keyboard status changes. * * @param listener The listener to set. */ public abstract void setOnHardKeyboardStatusChangeListener( OnHardKeyboardStatusChangeListener listener); }
services/core/java/com/android/server/InputMethodManagerService.java +21 −18 Original line number Diff line number Diff line Loading @@ -33,7 +33,6 @@ import com.android.internal.view.IInputMethodManager; import com.android.internal.view.IInputMethodSession; import com.android.internal.view.InputBindResult; import com.android.server.statusbar.StatusBarManagerService; import com.android.server.wm.WindowManagerService; import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; Loading Loading @@ -109,6 +108,7 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.view.WindowManager; import android.view.WindowManagerInternal; import android.view.inputmethod.EditorInfo; import android.view.inputmethod.InputBinding; import android.view.inputmethod.InputMethod; Loading Loading @@ -182,11 +182,11 @@ public class InputMethodManagerService extends IInputMethodManager.Stub final InputMethodSettings mSettings; final SettingsObserver mSettingsObserver; final IWindowManager mIWindowManager; final WindowManagerInternal mWindowManagerInternal; final HandlerCaller mCaller; final boolean mHasFeature; private InputMethodFileManager mFileManager; private final HardKeyboardListener mHardKeyboardListener; private final WindowManagerService mWindowManagerService; private final AppOpsManager mAppOpsManager; final InputBindResult mNoBinding = new InputBindResult(null, null, null, -1, -1); Loading Loading @@ -710,7 +710,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub } private class HardKeyboardListener implements WindowManagerService.OnHardKeyboardStatusChangeListener { implements WindowManagerInternal.OnHardKeyboardStatusChangeListener { @Override public void onHardKeyboardStatusChange(boolean available) { mHandler.sendMessage(mHandler.obtainMessage(MSG_HARD_KEYBOARD_SWITCH_CHANGED, Loading @@ -732,7 +732,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub } } public InputMethodManagerService(Context context, WindowManagerService windowManager) { public InputMethodManagerService(Context context) { mIPackageManager = AppGlobals.getPackageManager(); mContext = context; mRes = context.getResources(); Loading @@ -741,13 +741,13 @@ public class InputMethodManagerService extends IInputMethodManager.Stub mSettingsObserver = new SettingsObserver(mHandler); mIWindowManager = IWindowManager.Stub.asInterface( ServiceManager.getService(Context.WINDOW_SERVICE)); mWindowManagerInternal = LocalServices.getService(WindowManagerInternal.class); mCaller = new HandlerCaller(context, null, new HandlerCaller.Callback() { @Override public void executeMessage(Message msg) { handleMessage(msg); } }, true /*asyncHandler*/); mWindowManagerService = windowManager; mAppOpsManager = (AppOpsManager) mContext.getSystemService(Context.APP_OPS_SERVICE); mHardKeyboardListener = new HardKeyboardListener(); mHasFeature = context.getPackageManager().hasSystemFeature( Loading Loading @@ -1045,7 +1045,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub mShowOngoingImeSwitcherForPhones = mRes.getBoolean( com.android.internal.R.bool.show_ongoing_ime_switcher); if (mShowOngoingImeSwitcherForPhones) { mWindowManagerService.setOnHardKeyboardStatusChangeListener( mWindowManagerInternal.setOnHardKeyboardStatusChangeListener( mHardKeyboardListener); } buildInputMethodListLocked(mMethodList, mMethodMap, Loading Loading @@ -1507,7 +1507,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub if (DEBUG) Slog.v(TAG, "Removing window token: " + mCurToken); if ((mImeWindowVis & InputMethodService.IME_ACTIVE) != 0 && savePosition) { // The current IME is shown. Hence an IME switch (transition) is happening. mWindowManagerService.saveLastInputMethodWindowForTransition(); mWindowManagerInternal.saveLastInputMethodWindowForTransition(); } mIWindowManager.removeWindowToken(mCurToken); } catch (RemoteException e) { Loading Loading @@ -1641,7 +1641,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub if (mSwitchingDialog != null) return false; if (isScreenLocked()) return false; if ((visibility & InputMethodService.IME_ACTIVE) == 0) return false; if (mWindowManagerService.isHardKeyboardAvailable()) { if (mWindowManagerInternal.isHardKeyboardAvailable()) { // When physical keyboard is attached, we show the ime switcher (or notification if // NavBar is not available) because SHOW_IME_WITH_HARD_KEYBOARD settings currently // exists in the IME switcher dialog. Might be OK to remove this condition once Loading Loading @@ -1753,8 +1753,9 @@ public class InputMethodManagerService extends IInputMethodManager.Stub mImeSwitcherNotification.setContentTitle(title) .setContentText(summary) .setContentIntent(mImeSwitchPendingIntent); try { if ((mNotificationManager != null) && !mWindowManagerService.hasNavigationBar()) { && !mIWindowManager.hasNavigationBar()) { if (DEBUG) { Slog.d(TAG, "--- show notification: label = " + summary); } Loading @@ -1763,6 +1764,8 @@ public class InputMethodManagerService extends IInputMethodManager.Stub mImeSwitcherNotification.build(), UserHandle.ALL); mNotificationShown = true; } } catch (RemoteException e) { } } else { if (mNotificationShown && mNotificationManager != null) { if (DEBUG) { Loading Loading @@ -2527,7 +2530,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub @Override public int getInputMethodWindowVisibleHeight() { return mWindowManagerService.getInputMethodWindowVisibleHeight(); return mWindowManagerInternal.getInputMethodWindowVisibleHeight(); } @Override Loading Loading @@ -3041,7 +3044,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub mSwitchingDialogTitleView = tv; mSwitchingDialogTitleView .findViewById(com.android.internal.R.id.hard_keyboard_section) .setVisibility(mWindowManagerService.isHardKeyboardAvailable() .setVisibility(mWindowManagerInternal.isHardKeyboardAvailable() ? View.VISIBLE : View.GONE); final Switch hardKeySwitch = (Switch) mSwitchingDialogTitleView.findViewById( com.android.internal.R.id.hard_keyboard_switch); Loading
services/core/java/com/android/server/wm/WindowManagerService.java +36 −36 Original line number Diff line number Diff line Loading @@ -552,7 +552,7 @@ public class WindowManagerService extends IWindowManager.Stub boolean mHardKeyboardAvailable; boolean mShowImeWithHardKeyboard; OnHardKeyboardStatusChangeListener mHardKeyboardStatusChangeListener; WindowManagerInternal.OnHardKeyboardStatusChangeListener mHardKeyboardStatusChangeListener; SettingsObserver mSettingsObserver; private final class SettingsObserver extends ContentObserver { Loading Loading @@ -6808,12 +6808,6 @@ public class WindowManagerService extends IWindowManager.Stub mPolicy.adjustConfigurationLw(config, keyboardPresence, navigationPresence); } public boolean isHardKeyboardAvailable() { synchronized (mWindowMap) { return mHardKeyboardAvailable; } } public void updateShowImeWithHardKeyboard() { synchronized (mWindowMap) { final boolean showImeWithHardKeyboard = Settings.Secure.getIntForUser( Loading @@ -6826,16 +6820,9 @@ public class WindowManagerService extends IWindowManager.Stub } } public void setOnHardKeyboardStatusChangeListener( OnHardKeyboardStatusChangeListener listener) { synchronized (mWindowMap) { mHardKeyboardStatusChangeListener = listener; } } void notifyHardKeyboardStatusChange() { final boolean available; final OnHardKeyboardStatusChangeListener listener; final WindowManagerInternal.OnHardKeyboardStatusChangeListener listener; synchronized (mWindowMap) { listener = mHardKeyboardStatusChangeListener; available = mHardKeyboardAvailable; Loading Loading @@ -10431,23 +10418,6 @@ public class WindowManagerService extends IWindowManager.Stub } } // It is assumed that this method is called only by InputMethodManagerService. public void saveLastInputMethodWindowForTransition() { synchronized (mWindowMap) { // TODO(multidisplay): Pass in the displayID. DisplayContent displayContent = getDefaultDisplayContentLocked(); if (mInputMethodWindow != null) { mPolicy.setLastInputMethodWindowLw(mInputMethodWindow, mInputMethodTarget); } } } public int getInputMethodWindowVisibleHeight() { synchronized (mWindowMap) { return mPolicy.getInputMethodWindowVisibleHeightLw(); } } @Override public boolean hasNavigationBar() { return mPolicy.hasNavigationBar(); Loading Loading @@ -11037,10 +11007,6 @@ public class WindowManagerService extends IWindowManager.Stub synchronized (mWindowMap) { } } public interface OnHardKeyboardStatusChangeListener { public void onHardKeyboardStatusChange(boolean available); } void debugLayoutRepeats(final String msg, int pendingLayoutChanges) { if (mLayoutRepeatCount >= LAYOUT_REPEAT_THRESHOLD) { Slog.v(TAG, "Layouts looping: " + msg + ", mPendingLayoutChanges = 0x" + Loading Loading @@ -11348,5 +11314,39 @@ public class WindowManagerService extends IWindowManager.Stub mAppTransition.registerListenerLocked(listener); } } @Override public int getInputMethodWindowVisibleHeight() { synchronized (mWindowMap) { return mPolicy.getInputMethodWindowVisibleHeightLw(); } } @Override public void saveLastInputMethodWindowForTransition() { synchronized (mWindowMap) { // TODO(multidisplay): Pass in the displayID. DisplayContent displayContent = getDefaultDisplayContentLocked(); if (mInputMethodWindow != null) { mPolicy.setLastInputMethodWindowLw(mInputMethodWindow, mInputMethodTarget); } } } @Override public boolean isHardKeyboardAvailable() { synchronized (mWindowMap) { return mHardKeyboardAvailable; } } @Override public void setOnHardKeyboardStatusChangeListener( OnHardKeyboardStatusChangeListener listener) { synchronized (mWindowMap) { mHardKeyboardStatusChangeListener = listener; } } } }
services/java/com/android/server/SystemServer.java +1 −1 Original line number Diff line number Diff line Loading @@ -546,7 +546,7 @@ public final class SystemServer { if (mFactoryTestMode != FactoryTest.FACTORY_TEST_LOW_LEVEL) { try { Slog.i(TAG, "Input Method Service"); imm = new InputMethodManagerService(context, wm); imm = new InputMethodManagerService(context); ServiceManager.addService(Context.INPUT_METHOD_SERVICE, imm); } catch (Throwable e) { reportWtf("starting Input Manager Service", e); Loading