diff options
| author | 2015-08-25 20:42:25 +0000 | |
|---|---|---|
| committer | 2015-08-25 20:42:25 +0000 | |
| commit | e3e7b52324c5c829388dd2820810acef56328c17 (patch) | |
| tree | e7cf41bfb8489804de35cf54f061396bbd3464eb | |
| parent | f208a1a0d18c8675f7390d7badab81b39fd23d1b (diff) | |
| parent | 7309b123c423504bb18e3d78dd22a36f7271676a (diff) | |
Merge "Leverage WindowManagerInternal for private communication."
4 files changed, 90 insertions, 55 deletions
diff --git a/core/java/android/view/WindowManagerInternal.java b/core/java/android/view/WindowManagerInternal.java index 7b4640b46c62..a6d99325b094 100644 --- a/core/java/android/view/WindowManagerInternal.java +++ b/core/java/android/view/WindowManagerInternal.java @@ -120,6 +120,13 @@ public abstract class WindowManagerInternal { } /** + * 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} * within a surface transaction at a later time. @@ -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); } diff --git a/services/core/java/com/android/server/InputMethodManagerService.java b/services/core/java/com/android/server/InputMethodManagerService.java index 0a0ee3fd36dd..4b095fdffc04 100644 --- a/services/core/java/com/android/server/InputMethodManagerService.java +++ b/services/core/java/com/android/server/InputMethodManagerService.java @@ -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; @@ -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; @@ -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); @@ -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, @@ -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(); @@ -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( @@ -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, @@ -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) { @@ -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 @@ -1753,15 +1753,18 @@ public class InputMethodManagerService extends IInputMethodManager.Stub mImeSwitcherNotification.setContentTitle(title) .setContentText(summary) .setContentIntent(mImeSwitchPendingIntent); - if ((mNotificationManager != null) - && !mWindowManagerService.hasNavigationBar()) { - if (DEBUG) { - Slog.d(TAG, "--- show notification: label = " + summary); + try { + if ((mNotificationManager != null) + && !mIWindowManager.hasNavigationBar()) { + if (DEBUG) { + Slog.d(TAG, "--- show notification: label = " + summary); + } + mNotificationManager.notifyAsUser(null, + com.android.internal.R.string.select_input_method, + mImeSwitcherNotification.build(), UserHandle.ALL); + mNotificationShown = true; } - mNotificationManager.notifyAsUser(null, - com.android.internal.R.string.select_input_method, - mImeSwitcherNotification.build(), UserHandle.ALL); - mNotificationShown = true; + } catch (RemoteException e) { } } else { if (mNotificationShown && mNotificationManager != null) { @@ -2527,7 +2530,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub @Override public int getInputMethodWindowVisibleHeight() { - return mWindowManagerService.getInputMethodWindowVisibleHeight(); + return mWindowManagerInternal.getInputMethodWindowVisibleHeight(); } @Override @@ -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); diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java index 7b4c2a0c65e8..52aaf6439d72 100644 --- a/services/core/java/com/android/server/wm/WindowManagerService.java +++ b/services/core/java/com/android/server/wm/WindowManagerService.java @@ -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 { @@ -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( @@ -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; @@ -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(); @@ -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" + @@ -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; + } + } + } } diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java index ed32c768bf3b..21dd647b6785 100644 --- a/services/java/com/android/server/SystemServer.java +++ b/services/java/com/android/server/SystemServer.java @@ -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); |