Merge changes Iee47e374,Icc64942a

* changes:
  Use Context.getSystemService(Class<T>) for InputManager.
  Use Context.getSystemService(Class<T>) for InputMethodManager.
This commit is contained in:
Yohei Yukawa
2015-11-26 08:16:33 +00:00
committed by Android (Google) Code Review
12 changed files with 21 additions and 28 deletions

View File

@@ -129,8 +129,8 @@ public class NativeActivity extends Activity implements SurfaceHolder.Callback2,
String libname = "main";
String funcname = "ANativeActivity_onCreate";
ActivityInfo ai;
mIMM = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
mIMM = getSystemService(InputMethodManager.class);
getWindow().takeSurface(this);
getWindow().takeInputQueue(this);

View File

@@ -505,8 +505,7 @@ public class SearchDialog extends Dialog {
// We made sure the IME was displayed, so also make sure it is closed
// when we go away.
InputMethodManager imm = (InputMethodManager)getContext()
.getSystemService(Context.INPUT_METHOD_SERVICE);
InputMethodManager imm = getContext().getSystemService(InputMethodManager.class);
if (imm != null) {
imm.hideSoftInputFromWindow(
getWindow().getDecorView().getWindowToken(), 0);
@@ -643,8 +642,7 @@ public class SearchDialog extends Dialog {
public void onBackPressed() {
// If the input method is covering the search dialog completely,
// e.g. in landscape mode with no hard keyboard, dismiss just the input method
InputMethodManager imm = (InputMethodManager)getContext()
.getSystemService(Context.INPUT_METHOD_SERVICE);
InputMethodManager imm = getContext().getSystemService(InputMethodManager.class);
if (imm != null && imm.isFullscreenMode() &&
imm.hideSoftInputFromWindow(getWindow().getDecorView().getWindowToken(), 0)) {
return;

View File

@@ -61,8 +61,7 @@ public class FindActionModeCallback implements ActionMode.Callback, TextWatcher,
setText("");
mMatches = (TextView) mCustomView.findViewById(
com.android.internal.R.id.matches);
mInput = (InputMethodManager)
context.getSystemService(Context.INPUT_METHOD_SERVICE);
mInput = context.getSystemService(InputMethodManager.class);
mResources = context.getResources();
}

View File

@@ -5755,8 +5755,8 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
// The editor is off in its own window; we need to be
// the one that does this.
if (editorAction == EditorInfo.IME_ACTION_DONE) {
InputMethodManager imm = (InputMethodManager)
getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
InputMethodManager imm =
getContext().getSystemService(InputMethodManager.class);
if (imm != null) {
imm.hideSoftInputFromWindow(getWindowToken(), 0);
}

View File

@@ -152,8 +152,7 @@ public class SearchView extends LinearLayout implements CollapsibleActionView {
*/
private Runnable mShowImeRunnable = new Runnable() {
public void run() {
InputMethodManager imm = (InputMethodManager)
getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
InputMethodManager imm = getContext().getSystemService(InputMethodManager.class);
if (imm != null) {
imm.showSoftInputUnchecked(0, null);
@@ -912,8 +911,7 @@ public class SearchView extends LinearLayout implements CollapsibleActionView {
post(mShowImeRunnable);
} else {
removeCallbacks(mShowImeRunnable);
InputMethodManager imm = (InputMethodManager)
getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
InputMethodManager imm = getContext().getSystemService(InputMethodManager.class);
if (imm != null) {
imm.hideSoftInputFromWindow(getWindowToken(), 0);
@@ -1768,8 +1766,8 @@ public class SearchView extends LinearLayout implements CollapsibleActionView {
super.onWindowFocusChanged(hasWindowFocus);
if (hasWindowFocus && mSearchView.hasFocus() && getVisibility() == VISIBLE) {
InputMethodManager inputManager = (InputMethodManager) getContext()
.getSystemService(Context.INPUT_METHOD_SERVICE);
InputMethodManager inputManager =
getContext().getSystemService(InputMethodManager.class);
inputManager.showSoftInput(this, 0);
// If in landscape mode, then make sure that
// the ime is in front of the dropdown.

View File

@@ -137,7 +137,7 @@ public class PointerLocationView extends View implements InputDeviceListener,
super(c);
setFocusableInTouchMode(true);
mIm = (InputManager)c.getSystemService(Context.INPUT_SERVICE);
mIm = c.getSystemService(InputManager.class);
mVC = ViewConfiguration.get(c);
mTextPaint = new Paint();

View File

@@ -556,8 +556,7 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat
// Make sure the IME is not on the way of preview as
// the user may have used it to type copies or range.
InputMethodManager imm = (InputMethodManager) getSystemService(
Context.INPUT_METHOD_SERVICE);
InputMethodManager imm = getSystemService(InputMethodManager.class);
imm.hideSoftInputFromWindow(mDestinationSpinner.getWindowToken(), 0);
}

View File

@@ -180,7 +180,7 @@ public class KeyboardUI extends SystemUI implements InputManager.OnTabletModeCha
mProfileManager = bluetoothManager.getProfileManager();
bluetoothManager.getEventManager().registerCallback(new BluetoothCallbackHandler());
InputManager im = (InputManager) context.getSystemService(Context.INPUT_SERVICE);
InputManager im = context.getSystemService(InputManager.class);
im.registerOnTabletModeChangedListener(this, mHandler);
mInTabletMode = im.isInTabletMode();

View File

@@ -143,7 +143,7 @@ public class NavigationBarView extends LinearLayout {
private final OnClickListener mImeSwitcherClickListener = new OnClickListener() {
@Override
public void onClick(View view) {
((InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE))
mContext.getSystemService(InputMethodManager.class)
.showInputMethodPicker(true /* showAuxiliarySubtypes */);
}
};

View File

@@ -446,8 +446,7 @@ public class TextServicesManagerService extends ITextServicesManager.Stub {
String candidateLocale = null;
if (hashCode == 0) {
// Spell checker language settings == "auto"
final InputMethodManager imm =
(InputMethodManager)mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
final InputMethodManager imm = mContext.getSystemService(InputMethodManager.class);
if (imm != null) {
final InputMethodSubtype currentInputMethodSubtype =
imm.getCurrentInputMethodSubtype();

View File

@@ -223,7 +223,7 @@ public class VibratorService extends IVibratorService.Stub
}
public void systemReady() {
mIm = (InputManager)mContext.getSystemService(Context.INPUT_SERVICE);
mIm = mContext.getSystemService(InputManager.class);
mSettingObserver = new SettingsObserver(mH);
mPowerManagerInternal = LocalServices.getService(PowerManagerInternal.class);

View File

@@ -5567,8 +5567,8 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
// InputMethodManager fetches input methods for current user.
// So this can only be set when calling user is the current user
// or parent is current user in case of managed profiles.
InputMethodManager inputMethodManager = (InputMethodManager) mContext
.getSystemService(Context.INPUT_METHOD_SERVICE);
InputMethodManager inputMethodManager =
mContext.getSystemService(InputMethodManager.class);
List<InputMethodInfo> enabledImes = inputMethodManager.getEnabledInputMethodList();
if (enabledImes != null) {
@@ -5646,8 +5646,8 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
// If we have a permitted list add all system input methods.
if (result != null) {
InputMethodManager inputMethodManager = (InputMethodManager) mContext
.getSystemService(Context.INPUT_METHOD_SERVICE);
InputMethodManager inputMethodManager =
mContext.getSystemService(InputMethodManager.class);
List<InputMethodInfo> imes = inputMethodManager.getInputMethodList();
long id = mInjector.binderClearCallingIdentity();
try {