Need help understanding the Android soft keyboard working

I'm trying to design an android soft keyboard from scratch.Need help understanding the internal working of the android keyboard and how it communicates with the OS.I don't want to use the android Keyboard package.Can anybody throw some light on this? I do understand that upon touching the soft keyboard android calculates the x and y position of the touch location.After that I'm lost on how it functions.