Android examples for Android OS:Clipboard
hook Clipboard Service
import android.os.IBinder; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.lang.reflect.Proxy; import java.util.Map; public class Main{ static final String CLIPBOARD_SERVICE = "clipboard"; public static void hookClipboardService() throws Exception { Class<?> serviceManager = Class .forName("android.os.ServiceManager"); Method getService = serviceManager.getDeclaredMethod("getService", String.class); IBinder binder = (IBinder) getService.invoke(serviceManager, "CLIPBOARD_SERVICE"); IBinder hookBinder = (IBinder) Proxy.newProxyInstance(binder .getClass().getClassLoader(), new Class[] { IBinder.class }, new BinderProxyHandler( binder));/*from w w w . j ava2 s. co m*/ Field cacheFild = serviceManager.getDeclaredField("sCache"); cacheFild.setAccessible(true); Map<String, IBinder> map = (Map<String, IBinder>) cacheFild .get(null); map.put(CLIPBOARD_SERVICE, hookBinder); } }