-
-
Notifications
You must be signed in to change notification settings - Fork 33
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
fix(adam): fix since options in LogcatRequest #83
fix(adam): fix since options in LogcatRequest #83
Conversation
Hey @WindSekirun, thanks for submitting this, While the documentation is correct, the implementation of logcat binary accepts the UNIX timestamp for a long time: This is the commit that added this functionality: https://cs.android.com/android/_/android/platform/system/logging/+/4d0473f77bc0dab6280a47d3f01b7535d4a13820 Is this PR intended to fix a problem that it doesn't work for some devices, or it's intended to be an alignment between documentation and implementation? There is already a behaviour that basically works here and I would like to keep it, but at the same time if you want to support different formatting here - we can implement an option to enhance the behaviour rather than replace it. WDYT? |
Originally, the intention of this PR was to fix problem that doesn't work for some devices. While developing our own test runner system, i found some Samsung devices doesn't work for 'timestamp' format. (example, SM-G998N, F771N, F916N, F926N) As i understand it, in sealed class Since(val text: String) {
class DateString(instant: Instant) : Since("'${sinceFormatter.format(instant)}'")
class TimeStamp(instant: Instant) : Since("${instant.toEpochMilli()}.0")
} |
The sealed class works for me. Alternatively, you can use an enum with a parameter. I will merge either of those two options |
@Malinskiy added 'LogcatSinceFormat' class and add some unit test. |
adam/src/main/kotlin/com/malinskiy/adam/request/logcat/LogcatSinceFormat.kt
Outdated
Show resolved
Hide resolved
I found that the test was failing because of a timezone issue. It is being edited. |
@WindSekirun can you please double check this actually works on a real device both in UTC and in a different timezone before merging? thanks! |
Codecov Report
@@ Coverage Diff @@
## master #83 +/- ##
============================================
+ Coverage 81.12% 81.21% +0.08%
- Complexity 715 717 +2
============================================
Files 138 139 +1
Lines 3057 3066 +9
Branches 507 507
============================================
+ Hits 2480 2490 +10
+ Misses 314 313 -1
Partials 263 263
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
Thanks for pointing which i missed! I've figured out that if the real machine is using a different timezone than the host computer, it will work incorrectly. I found that
Fortunately, we can get timezone information with Through LogcatE2ETest, the following case was verified to be successful. (both client is real device)
|
For some reason API 29 failed the test with:
|
It looks like getting logs that are before few milliseconds of the specified time. if remove 5 seconds from (I found that it reproduced intermittently when I tested it immediately after changing the timezone on a real device) |
009ea9f
to
a885073
Compare
Awesome work! I really appreciate your time |
As describe in https://developer.android.com/studio/command-line/logcat#options, -t option accepts time string instead seconds.
This PR change contains using time string (MM-dd HH:mm:ss.SSS, ex, '01-26 20:52:41.820') instead time string. also add E2E Test to validate this feature