They say pain is the only true catalyst for change and it was this pain that drove me to finally find the answer. I found that the following adb command will tell you whether or not the keyboard is open:
adb shell dumpsys input_method | grep
mInputShown
After running this command you may find that the information displayed is more than what you need. So how do i find what Im looking for and use this in a Java function that I can call at any time during a Uiautomator test? Here is the solution:You can use this function to find out if the keyboard is currently open and then close it. This is the best way to make sure you don't attempt to close the keyboard when it isn't open which would result in clicking the Phones BACK button and some potential confusion as to what went wrong
If you disagree, have any questions or would be interested in seeing a tutorial about anything else Android or Automation related, hit me up on Google+.