DevelopFreedom / logmein-android

Automatically login to University WiFi with your Android
https://play.google.com/store/apps/details?id=org.developfreedom.logmein
GNU General Public License v3.0
16 stars 11 forks source link

WiFi automatic url detection #14

Open ylogx opened 9 years ago

ylogx commented 9 years ago

This is one of the high priority task still pending. Due to this the app can't be useful outside PU@Campus and hence is blocking release anywhere outside. The chief goal is to get the url dynamically instead of hard-coded string (http:172....).

There are two type of cases where this happens . . .

CASE 1: Redirections 302
Ashish-Bansal commented 9 years ago

I think we should use some html parser (may be jsoup). In most of the forms, there would be two fields, one for email and other for password and then one input field type submit. So we can extract those input fields and get the name of the fields using parser and can also check form submit type method used (get or post). May be something like this : http://pastebin.com/4zEYcFsy . Although I have not tested it and it is not complete.

ylogx commented 9 years ago

Looks like a good start. I think you have the push access now. Let's start doing this in a separate branch and see where we reach.

Ashish-Bansal commented 9 years ago

I don't think we can make it global. Although login is possible but still we can't find out the logout URL by any means. Instead rating of app would decrease and users will give negative comments too that it does not works fine and blah blah.....!!

ylogx commented 9 years ago

Login is what we need to worry about right now. Login is possible. Definitely possible. If google can find and show Sign in notif, then it is definitely possible. AFA logout is concerned we can always disable that using seperate layouts (based on hasLogoutCapability function or something) etc. PS: Rating is not the driving force. The main motive is to build the product that we started with in the first place. We don't have commercial goals from this application, so ratings don't matter. Anyway if the final product is useful, positive response will follow eventually

ylogx commented 9 years ago

Hey @Ashish-Bansal I just pushed 862ab22. I can't make this tree work man. I tried and login and logout gives no response. Can you please look into it and debug it further.

Ashish-Bansal commented 9 years ago

Well I tried it today morning but didn't got the much time to test it. I was able to log in using it. But I tried log out but it didn't worked. I thought there must be some other issue with it as I didn't changed anything regarding that. But now it struck my mind. If you are already logged in and you press up log in, this changes the BASE_URL to http://www.google.co.in/........ and after that logout would not work as BASE_URL+ "?cmd=logout" is not logout url. That's why logout is not working. While testing it on home network, I just figured out that If user presses login multiple times, it is not gonna send requests multiple times. Only one thread will run and all other would be in queue and if first one does not finishes up(possible!!) or lets consider other one in which first one request finishes successfully(user login is successful) but next request is not gonna finish up because regex match would fail and stuck up there, then nothing is gonna work until user restarts it. We need something else to kill that thread or some better way.

ylogx commented 9 years ago

Here is a recent logcat at this tree 5569357 http://fpaste.org/150209/

Ashish-Bansal commented 9 years ago

Okay So, I found two issues in it.

  1. I know this one -> java.lang.IllegalStateException: Cannot execute task: the task is already running. It is in line : https://github.com/DevelopFreedom/logmein-android/blob/ashish-merge/app/src/main/java/org/developfreedom/logmein/LoginService.java#L73

Although I have used m_ping.cancel(true); but I don't know where I am making mistake.

  1. It didn't worked on local server page.[Logcat line no. 351] Actually I didn't knew that in local server page, Address is like this -> https://securelogin.arubanetworks.com...... .I had made regex for ip address http://123.123.123.123/anything?anything.... Although we can use another regex but then another problem will arise. If I changed the regex here (https://github.com/DevelopFreedom/logmein-android/blob/ashish-merge/app/src/main/java/org/developfreedom/logmein/NetworkEngine.java#L366) , then m.find() would be true in most of the cases and url would/may be wrong. Any suggestions??