Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The GetRandomAndriodVersion() creates endless loop #40

Closed
aspmaker opened this issue Sep 12, 2018 · 14 comments
Closed

The GetRandomAndriodVersion() creates endless loop #40

aspmaker opened this issue Sep 12, 2018 · 14 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@aspmaker
Copy link

GetRandomAndriodVersion() method when call to it 5-10 time, it returns the same API level. So infinite loop occurs. (Then AndroidVersions list all the becoming same.)

@ramtinak
Copy link
Owner

I test this method in a loop, but it's ok for me:

for (int i = 0; i < 50; i++)
{
    var device = AndroidDeviceGenerator.GetRandomAndroidDevice();
    Debug.WriteLine($"{device.HardwareManufacturer} - {device.HardwareModel}\t\t\t\t|\t{device.AndroidVersion.VersionNumber}\t|\t{device.AndroidVersion.APILevel}");
}

Output:

LGE - Nexus 4				|	5.0	|	21
asus - Nexus 7				|	7.0	|	24
Huawei - Nexus 6P			|	9.0	|	27
Sony - SO-02G				|	4.2	|	17
LGE - Nexus 5X				|	9.0	|	27
samsung - SM-T705			|	8.1	|	27
Sony - E6653				|	7.0	|	24
samsung - SM-N915W8			|	8.0	|	26
samsung - SM-G935T			|	4.4	|	19
Sony - E6653				|	7.0	|	24
samsung - SM-G935T			|	4.4	|	19
LGE - Nexus 4				|	5.0	|	21
samsung - SM-N915W8			|	8.0	|	26
LGE - Nexus 5				|	7.1	|	25
asus - Nexus 7				|	7.0	|	24
LGE - LG-LS970				|	9.0	|	27
asus - Nexus 7				|	4.0.3	|	15
samsung - SM-N900P			|	4.2	|	17
LGE - LG-LS970				|	9.0	|	27
samsung - SM-N900P			|	4.2	|	17
LGE - LG-LS970				|	9.0	|	27
asus - Nexus 7				|	4.0.3	|	15
samsung - SM-N915W8			|	8.0	|	26
LGE - Nexus 5X				|	9.0	|	27
LGE - LG-D500				|	4.1	|	16
HTC - HTC 10				|	4.3	|	18
asus - Nexus 7				|	7.0	|	24
Sony - E6653				|	7.0	|	24
HUAWEI - hi6250				|	4.3	|	18
asus - Nexus 7				|	4.0.3	|	15
samsung - SM-T705			|	8.1	|	27
LGE - LG-LS970				|	9.0	|	27
samsung - SM-N900P			|	4.2	|	17
LGE - Nexus 5X				|	9.0	|	27
HUAWEI - hi6250				|	4.3	|	18
LGE - LG-D500				|	4.1	|	16
LGE - LG-LS970				|	9.0	|	27
samsung - SM-T310			|	7.0	|	24
Huawei - Nexus 6P			|	9.0	|	27
HTC - HTC 10				|	4.3	|	18
LGE - Nexus 4				|	5.0	|	21
LGE - LG-LS970				|	9.0	|	27
Sony - SO-02G				|	4.2	|	17
samsung - samsungexynos7420		|	8.0	|	26
samsung - SM-G900F			|	4.2	|	17
LGE - Nexus 4				|	5.0	|	21
samsung - SM-G900F			|	4.2	|	17
LGE - LG-D500				|	4.1	|	16
LGE - Nexus 5				|	7.1	|	25
LGE - Nexus 5X				|	9.0	|	27

@aspmaker
Copy link
Author

aspmaker commented Sep 13, 2018

i tested the code its beginning to end with other methods together. This is a web app. Page reload every 3 seconds and get user media list. And i got this result. Please watch the video.

https://www.youtube.com/watch?v=Vz5UzZlZLGA

@ramtinak ramtinak added bug Something isn't working help wanted Extra attention is needed labels Sep 13, 2018
@aspmaker
Copy link
Author

i fixed bug like this:

in AndroidVersion.cs change like that:
private static AndroidVersion LastAndriodVersion;
to
private static AndroidVersion LastAndriodVersion = AndroidVersions[AndroidVersions.Count - 1];

return LastAndriodVersion = androidVersion;
to
return androidVersion;

in AndroidDevice.cs change like that:
public AndroidVersion AndroidVersion { get; set; } = AndroidVersion.GetRandomAndriodVersion();
to
public AndroidVersion AndroidVersionx { get; set; } = AndroidVersion.GetRandomAndriodVersion();
(this name replaced everywhere used)

@ramtinak
Copy link
Owner

ramtinak commented Sep 13, 2018

Please send a pull request for your fix

@aspmaker
Copy link
Author

Sorry but it dont know how can i do it :( you must do this changes and update project.

@ramtinak ramtinak added the fixed bug fixed label Sep 13, 2018
@ramtinak
Copy link
Owner

Added bfd5253 .
wait for v1.1.0.3

@ramtinak ramtinak removed the fixed bug fixed label Sep 13, 2018
@ramtinak
Copy link
Owner

ramtinak commented Sep 13, 2018

Find a bug while loading session.
Please don't use new version.
Can you do one thing? Only change this part of old commit:
return LastAndriodVersion = androidVersion
to
return androidVersion

Without changing AndroidVersion to AndroidVersionx!
And try it. Let me know.

@ramtinak ramtinak reopened this Sep 13, 2018
@aspmaker
Copy link
Author

i tried this. But not worked correctly. Because it is always overwrite to old list. So method is becoming to endless loop.
When change;

public AndroidVersion AndroidVersion { get; set; } = AndroidVersion.GetRandomAndriodVersion();
to
public AndroidVersion AndroidVer { get; set; } = AndroidVersion.GetRandomAndriodVersion();

and

return LastAndriodVersion = androidVersion;
to
return androidVersion;

and

private static AndroidVersion LastAndriodVersion;
to
private static AndroidVersion LastAndriodVersion = AndroidVersions[AndroidVersions.Count - 1];

it is working perfectly.

Note: if you change only
return LastAndriodVersion = androidVersion;
to
return androidVersion;

You must change this line
private static AndroidVersion LastAndriodVersion;
to
private static AndroidVersion LastAndriodVersion = AndroidVersions[AndroidVersions.Count - 1];

because LastAndriodVersion is always default value = null.
And if you change only this line, always is happening endless loop

@ramtinak
Copy link
Owner

Please try this one:
Change:

return LastAndriodVersion = androidVersion;

to

LastAndriodVersion = androidVersion;
return androidVersion;

then test it.

@aspmaker
Copy link
Author

No. it is same. Overwrite to list!

test12

@ramtinak
Copy link
Owner

OK, I will changed to AndroidVer but you need to login again,
If you didn't new login, every time you load your old account session, android device will change.
Because it saved as AndroidVersion not AndroidVer.

wait for v1.1.0.5

@aspmaker
Copy link
Author

Ok. Thank you.

@ramtinak
Copy link
Owner

Added 3cdcb2f .

@aspmaker
Copy link
Author

aspmaker commented Sep 15, 2018

@ramtinak why i don't know but this problem continue again :( when using static class it is always overwrite itself. so i did something like that. Create a new class for AndroidVersion in Classess > Android > DeviceInfo > AndroidVersionClass.cs and change something in AndroidVersion.cs & AndroidDevice.cs. i hope this is help for that. i tested it is working.

DeviceInfo.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants