Hmm, so you can't get it to stay connected to the wireless connection, correct? Because if there is the slightest possibility that the wifi is still connected (which might be easier to achieve in the network settings menu), you could try this.
Code:
./adb shell am start -a android.intent.action.VIEW -d http://www.google.com
This should try to open google.com link in the browser, and from there complete the wifi signin.