Introduce IInputMethodManagerGlobal
In reality methods defined in IInputMethodManager are no more or less than a set of global methods, because you can write the following logic anywhere. var service = IInputMethodManager.Stub.asInterface( ServiceManager.getService(Context.INPUT_METHOD_SERVICE)); if (service != null) { try { service.doSomething(); } catch (RemoteException e) { e.rethrowFromSystemServer(); } } With above observation, this CL introduces IInputMethodManagerGlobal as a collection of static methods that invoke methods defined in IInputMethodManager so that other framework classes do not need to write the same piece of code. public final class IInputMethodManagerGlobal { public static void doSomething() { final var service = getService(); if (service != null) { try { service.doSomething(); } catch (RemoteException e) { e.rethrowFromSystemServer(); } } } ...... } This CL then simplifies ImeTracing to demonstrate how IInputMethodManagerGlobal can be used. Basically this is a mechanical refactoring. There should be no observable behavior change. Bug: 234882948 Test: presubmit Change-Id: I5412eb1d44e3d515ca955f00a2e777b659a15b14
Loading
Please register or sign in to comment