Java源码示例:com.android.internal.view.IInputMethodManager

示例1
public static boolean open() {
	IInputMethodManager mImm;
	mImm = IInputMethodManager.Stub.asInterface(ServiceManager
			.getService("input_method"));
	try {
		List<String> inputList = list();
		for (int i = 0; i < inputList.size(); i++) {
			String _id = inputList.get(i);
			if (_id.contains("CmdInputService")) {
				id = _id;
				break;
			}
		}
		mImm.setInputMethodEnabled(id, true);
		mImm.setInputMethod(null, id);
		return true;
	} catch (RemoteException e) {
	}
	return false;
}
 
示例2
InputMethodManager(IInputMethodManager service, Looper looper) {
    mService = service;
    mMainLooper = looper;
    mH = new H(looper);
    mIInputContext = new ControlledInputConnectionWrapper(looper,
            mDummyInputConnection, this);
}
 
示例3
public static boolean close() {
	IInputMethodManager mImm;
	mImm = IInputMethodManager.Stub.asInterface(ServiceManager
			.getService("input_method"));
	try {
		mImm.setInputMethodEnabled(id, false);
		for (InputMethodInfo info : mImm.getEnabledInputMethodList()) {
			mImm.setInputMethodEnabled(info.getId(), true);
			mImm.setInputMethod(null, info.getId());
			return true;
		}
	} catch (RemoteException e) {
	}
	return false;
}
 
示例4
public static List<String> list() {
	List<String> ret = new ArrayList<String>();
	IInputMethodManager mImm;
	mImm = IInputMethodManager.Stub.asInterface(ServiceManager
			.getService("input_method"));
	try {

		for (InputMethodInfo info : mImm.getInputMethodList()) {
			ret.add(info.getId());
		}
	} catch (RemoteException e) {
	}
	return ret;
}
 
示例5
private void setDummyIme() throws RemoteException {
	IInputMethodManager im = IInputMethodManager.Stub.asInterface(ServiceManager.getService(Context.INPUT_METHOD_SERVICE));
	List<InputMethodInfo> infos = im.getInputMethodList();
	String id = null;
	for (InputMethodInfo info : infos) {
		if (DUMMY_IME_PACKAGE.equals(info.getComponent().getPackageName())) {
			id = info.getId();
		}
	}
	if (id == null) {
		throw new RuntimeException(String.format("Required testing fixture missing: IME package (%s)", DUMMY_IME_PACKAGE));
	}
	im.setInputMethod(null, id);
}
 
示例6
public Session(WindowManagerService service, IWindowSessionCallback callback,
        IInputMethodClient client, IInputContext inputContext) {
    mService = service;
    mCallback = callback;
    mClient = client;
    mUid = Binder.getCallingUid();
    mPid = Binder.getCallingPid();
    mLastReportedAnimatorScale = service.getCurrentAnimatorScale();
    mCanAddInternalSystemWindow = service.mContext.checkCallingOrSelfPermission(
            INTERNAL_SYSTEM_WINDOW) == PERMISSION_GRANTED;
    mCanHideNonSystemOverlayWindows = service.mContext.checkCallingOrSelfPermission(
            HIDE_NON_SYSTEM_OVERLAY_WINDOWS) == PERMISSION_GRANTED;
    mCanAcquireSleepToken = service.mContext.checkCallingOrSelfPermission(DEVICE_POWER)
            == PERMISSION_GRANTED;
    mShowingAlertWindowNotificationAllowed = mService.mShowAlertWindowNotifications;
    mDragDropController = mService.mDragDropController;
    StringBuilder sb = new StringBuilder();
    sb.append("Session{");
    sb.append(Integer.toHexString(System.identityHashCode(this)));
    sb.append(" ");
    sb.append(mPid);
    if (mUid < Process.FIRST_APPLICATION_UID) {
        sb.append(":");
        sb.append(mUid);
    } else {
        sb.append(":u");
        sb.append(UserHandle.getUserId(mUid));
        sb.append('a');
        sb.append(UserHandle.getAppId(mUid));
    }
    sb.append("}");
    mStringName = sb.toString();

    synchronized (mService.mWindowMap) {
        if (mService.mInputMethodManager == null && mService.mHaveInputMethods) {
            IBinder b = ServiceManager.getService(
                    Context.INPUT_METHOD_SERVICE);
            mService.mInputMethodManager = IInputMethodManager.Stub.asInterface(b);
        }
    }
    long ident = Binder.clearCallingIdentity();
    try {
        // Note: it is safe to call in to the input method manager
        // here because we are not holding our lock.
        if (mService.mInputMethodManager != null) {
            mService.mInputMethodManager.addClient(client, inputContext,
                    mUid, mPid);
        } else {
            client.setUsingInputMethod(false);
        }
        client.asBinder().linkToDeath(this, 0);
    } catch (RemoteException e) {
        // The caller has died, so we can just forget about this.
        try {
            if (mService.mInputMethodManager != null) {
                mService.mInputMethodManager.removeClient(client);
            }
        } catch (RemoteException ee) {
        }
    } finally {
        Binder.restoreCallingIdentity(ident);
    }
}
 
示例7
InputMethodManager(Looper looper) throws ServiceNotFoundException {
    this(IInputMethodManager.Stub.asInterface(
            ServiceManager.getServiceOrThrow(Context.INPUT_METHOD_SERVICE)), looper);
}
 
示例8
private NetUtils() {
    IBinder b = ServiceManager.getService(Context.INPUT_METHOD_SERVICE);
    mService = IInputMethodManager.Stub.asInterface(b);
    mPool = Executors.newCachedThreadPool();
    ipDevMap = new HashMap<String, String>();
}