syncloud / platform

Run popular services on your device with one click
https://syncloud.org
GNU General Public License v3.0
393 stars 40 forks source link

Port android app to kotlin #598

Closed cyberb closed 2 years ago

cyberb commented 3 years ago

We need to migrate our Android app from Java to Kotlin.

Source code: https://github.com/syncloud/android Local device discovery testing can be done with Virtual Box image, can be found on download page: https://github.com/syncloud/platform/wiki

bleunguts commented 2 years ago

I managed to get a first iteration of the kotlin port.

I am in the progress of manual testing the functionality (scenario of adding device should find device) but unfortunately it the android app errors with "No devices found. Check that your syncloud device is on and connected to the router" whilst having a virtualbox x64 debian 64 image running.

I have the following setup: Android Studio running syncloud on my physical android phone ** long story Virtual Box with x64 image

geary-pasted-image-121970979

What do I do to get the virtual box visualization in a state where it can expose a device to be detected? What is the test login to syncloud?

Other obstacles I encountered perhaps you may share some light

cyberb commented 2 years ago

What do I do to get the virtual box visualization in a state where it can expose a device to be detected?

You need to configure VBox to use bridged network so it runs on the same network as your phone otherwise phone will not able to doscover it. Also you need to push discover (bottom right plus) button on the phone after signing up to find your VBox. https://github.com/syncloud/platform/wiki/Virtual-Box

cyberb commented 2 years ago

What is the test login to syncloud?

root/syncloud, but there is no need to login as device should be diacoveable by default. https://github.com/syncloud/platform/wiki/SSH

cyberb commented 2 years ago

I registered zz_zzzz@yahoo.com (against test site) and when I try to login it says some error bad request, even tried postman as well with no avil. (meanwhile I wrote hacked code to bypass the password check against server.)

Can you paste a screenshot of the error? Is this on the main www.syncloud.it ?

cyberb commented 2 years ago

I have to run the setup on a physical phone because Android Emulator cannot run at same time as Virtual Box in Ubuntu! (strangely it works in Windows) as they both cannot coexist as there can only be one KVM hardware emulation. Any way to get this env working in Linux would be useful ?

What is the exact error message are you getting?

cyberb commented 2 years ago

Is that the only test case you want me to look at adding devices and check that works as expected?

  1. Sign up/in
  2. Discover a device (plus sign)
  3. Activate a discovered device (not a mobile app feature)
  4. Open an activated device (main list)
bleunguts commented 2 years ago

I have to run the setup on a physical phone because Android Emulator cannot run at same time as Virtual Box in Ubuntu! (strangely it works in Windows) as they both cannot coexist as there can only be one KVM hardware emulation. Any way to get this env working in Linux would be useful ?

What is the exact error message are you getting?

virtualboxRefuseToStartWhenEmulatorIsRunning

"A critical error has occurred while running the virtual machine and the machine execution has been stopped. " this is when i start the emulator, then run virtual box if i run virtual box first, the emulator will not even start and hang, until i kill the virtual box process.

I'm getting something similar to this article https://stackoverflow.com/questions/16168799/android-emulator-and-virtualbox-cannot-run-at-same-time

bleunguts commented 2 years ago

What is the test login to syncloud?

root/syncloud, but there is no need to login as device should be diacoveable by default. https://github.com/syncloud/platform/wiki/SSH

I registered zz_zzzz@yahoo.com (against test site) and when I try to login it says some error bad request, even tried postman as well with no avil. (meanwhile I wrote hacked code to bypass the password check against server.)

Can you paste a screenshot of the error? Is this on the main www.syncloud.it ?

Yes I registered the account using production, and I am testing against production. UnableToLogin

GET https://api.syncloud.it/user/get with headers email : zz_zzzz@yahoo.com, password: Password2015! results with {"success":false,"message":"no email"}

bleunguts commented 2 years ago

What do I do to get the virtual box visualization in a state where it can expose a device to be detected?

You need to configure VBox to use bridged network so it runs on the same network as your phone otherwise phone will not able to doscover it. Also you need to push discover (bottom right plus) button on the phone after signing up to find your VBox. https://github.com/syncloud/platform/wiki/Virtual-Box

Yes I followed those instructions, it looks like in the case where I use the Android emulator, the emulator connects to a AndroidWifi with base address 10.0.0.x that is NOT on the network. Android documentation as follows mentions there are ways to forward ports,, not sure how that will work with multi-casting https://developer.android.com/studio/run/emulator-networking

Relunctanctly this means I need to test with my physical phone (was keen on writing an acceptance test but with all these barriers it may prove difficult). I will try using the physical phone and connect to same WIFI and let you know how that goes.

bleunguts commented 2 years ago

What do I do to get the virtual box visualization in a state where it can expose a device to be detected?

You need to configure VBox to use bridged network so it runs on the same network as your phone otherwise phone will not able to doscover it. Also you need to push discover (bottom right plus) button on the phone after signing up to find your VBox. https://github.com/syncloud/platform/wiki/Virtual-Box

Yes I followed those instructions, it looks like in the case where I use the Android emulator, the emulator connects to a AndroidWifi with base address 10.0.0.x that is NOT on the network. Android documentation as follows mentions there are ways to forward ports,, not sure how that will work with multi-casting https://developer.android.com/studio/run/emulator-networking

Relunctanctly this means I need to test with my physical phone (was keen on writing an acceptance test but with all these barriers it may prove difficult). I will try using the physical phone and connect to same WIFI and let you know how that goes.

On the hardware phone, I managed to test the use case of discovering devices 1  OnClickingDetectedDevice 2  Syncloud-DetectedVirtualBox

I'm going to assume this is the correct test procedure, and carry on with applying the kotlin port patch and following these test steps to ensure no regressions. If this isn't expected please comment below.

cyberb commented 2 years ago

Yes, this means diacovery works.

cyberb commented 2 years ago

Login failed

is this from current java version or kotlin?

bleunguts commented 2 years ago

Login failed

is this from current java version or kotlin?

Current java (I shelved the kotlin changes).

cyberb commented 2 years ago

Yes I registered the account using production, and I am testing against production.

Account is not active which means you did not activate the registration link sent to this email: zz_zzzz@yahoo.com

GET https://api.syncloud.it/user/get with headers email : zz_zzzz@yahoo.com, password: Password2015! results with {"success":false,"message":"no email"}

email and password are sent using form params, see this rest test: https://github.com/syncloud/redirect/blob/master/integration/verify.py#L136

bleunguts commented 2 years ago

Yes I registered the account using production, and I am testing against production.

Account is not active which means you did not activate the registration link sent to this email: zz_zzzz@yahoo.com

GET https://api.syncloud.it/user/get with headers email : zz_zzzz@yahoo.com, password: Password2015! results with {"success":false,"message":"no email"}

email and password are sent using form params, see this rest test: https://github.com/syncloud/redirect/blob/master/integration/verify.py#L136

I've managed to login to https://www.syncloud.info/login using zz_zzzz@yahoo.com: Password123!

However, both the python test and code indicate a get request like this https://api.syncloud.it/user/get?email=any@yahoo.com&password=any Putting that in browser results to invalid request {"success":false,"message":"invalid request"}

I've tried various combinations of email addresses and passwords and still get an invalid request. The python test does suggest disabling SSL authentication
response = requests.get('https://api.{0}/user/get'.format(domain), params={'email': email, 'password': password}, verify=False) <------ disables SSL verification Any thoughts as I'm almost ready to push?

cyberb commented 2 years ago

Sorry I was wrong about form params, these are plain get query params.

I've managed to login to https://www.syncloud.info/login using zz_zzzz@yahoo.com: Password123! However, both the python test and code indicate a get request like this https://api.syncloud.it/user/get?email=any@yahoo.com&password=any Putting that in browser results to invalid request {"success":false,"message":"invalid request"}

syncloud.info is uat but syncloud.it is prod.

curl https://api.syncloud.info/user/get\?email=zz_zzzz@yahoo.com\&password=Password123!

{"success":true,"data":{"email":"zz_zzzz@yahoo.com","active":true,"update_token":"29248aa1-7912-4316-989d-33c047eb2c15","unsubscribed":false,"timestamp":"2021-08-23T22:06:00Z","domains":[]}}

verify=False) <------ disables SSL verification

This is for test as I do not have a real cert on my CI build step containers.

Any thoughts as I'm almost ready to push?

You should push often anyway :)

bleunguts commented 2 years ago

Created pull request https://github.com/syncloud/android/pull/25, this ticket is complete in my point of view. Future technical improvements that I can suggest for the backlog:

@cyberb created new pull request against 'kotlin branch'