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

Add a dumpsys adb interceptor to add command line controls #6234

Merged
merged 1 commit into from
Sep 8, 2022

Conversation

kmadsen
Copy link
Contributor

@kmadsen kmadsen commented Aug 26, 2022

Description

This gives us the ability to define lifecycle aware adb commands that can alter the sdk state. It creates an open interface so that downstream solutions can define their own interceptors.

This pull requests adds a couple examples to the qa-test-app.

Another example I was thinking, is if we added a replay:lng:xx.xxxx replay:lat:yy.yyyy commands. That would allow you to run simulations with location data from external machines.

DropInUi commands

$ adb shell dumpsys activity service com.mapbox.navigation.core.trip.service.NavigationNotificationService dropin:start_free_drive

dropin:start_free_drive allows you to trigger the NavigationViewApi.startFreeDrive function from the command line.

Navigation commands

$ adb shell dumpsys activity service com.mapbox.navigation.core.trip.service.NavigationNotificationService distance_unit_type:metric

There is not really a mechanism to change the distance formatter unit type. But this interceptor makes it easy, with this command you can override the distance formatter type.

Command line experience

Full explanation when no arguments are passed

➜  adb shell dumpsys activity service com.mapbox.navigation.core.trip.service.NavigationNotificationService
SERVICE com.mapbox.navigation.qa_test_app/com.mapbox.navigation.core.trip.service.NavigationNotificationService 94d4d24 pid=27593 user=0
  Client:
    Hello and welcome to the Mapbox Navigation dump!
      This allows you to control Mapbox Navigation
      from adb. Below are the commands and shortcuts
      that are available. If you'd like to create your
      own commands, look at the `MapboxDumpRegistry`.

    Command arguments can be passed as key:value and are separated by spaces.
      For example, if you pass data to dumpsys
      and you have added a `MapboxDumpInterceptor`, your
      interceptor will receive the command and the data.

      $ adb shell dumpsys activity service <service-package> turn_off_audio_guidance
      >> turn_off_audio_guidance

      $ adb shell dumpsys activity service <service-package> months:june months:july
      >> months:june months:july

      $ adb shell dumpsys activity service <service-package> "animal":{"age":4,"name":"cat","weight":{"units":"kilograms","value":4.5}}
      >> args[0] = animal:age:4
      >> args[1] = animal:name:cat
      >> args[2] = animal:weight:units:kilograms
      >> args[3] = animal:weight:value:4.5

      Warning: json format may give unexpected results because arguments are split by spaces.
      $ adb shell dumpsys activity service <service-package> "name":"big cat"
      >> args[0] = name:big
      >> args[1] = cat

    Request help for the commands available. This list is given with the `help` command.
    help:distance_formatter, Get the commands available from distance_formatter
    help:dropin, Get the commands available from dropin

More compact results when the help command is passed. From here you can discover the available commands.

➜  mapbox-navigation-android git:(km-update-unit-type-from-command-line) adb shell dumpsys activity service com.mapbox.navigation.core.trip.service.NavigationNotificationService help
SERVICE com.mapbox.navigation.qa_test_app/com.mapbox.navigation.core.trip.service.NavigationNotificationService 94d4d24 pid=27593 user=0
  Client:
    Request help for the commands available
    help:distance_formatter, Get the commands available from distance_formatter
    help:dropin, Get the commands available from dropin
    Processed: help

Get help on the specific command, for example help:dropin

➜  adb shell dumpsys activity service com.mapbox.navigation.core.trip.service.NavigationNotificationService help:dropin
SERVICE com.mapbox.navigation.qa_test_app/com.mapbox.navigation.core.trip.service.NavigationNotificationService 94d4d24 pid=27593 user=0
  Client:
    Available commands for help:dropin
       dropin:start_free_drive, Change the trip session state to free drive
    Processed: help:dropin

Execute the command that you found.

➜  adb shell dumpsys activity service com.mapbox.navigation.core.trip.service.NavigationNotificationService dropin:start_free_driv
e
SERVICE com.mapbox.navigation.qa_test_app/com.mapbox.navigation.core.trip.service.NavigationNotificationService 94d4d24 pid=27593 user=0
  Client:
    Processed: dropin:start_free_drive

@codecov
Copy link

codecov bot commented Aug 26, 2022

Codecov Report

Merging #6234 (10f78c5) into main (968e862) will decrease coverage by 0.08%.
The diff coverage is 47.31%.

❗ Current head 10f78c5 differs from pull request most recent head e14f29a. Consider uploading reports for the commit e14f29a to get more accurate results

Impacted file tree graph

@@             Coverage Diff              @@
##               main    #6234      +/-   ##
============================================
- Coverage     68.82%   68.74%   -0.09%     
- Complexity     4407     4432      +25     
============================================
  Files           663      667       +4     
  Lines         26490    26576      +86     
  Branches       3105     3117      +12     
============================================
+ Hits          18233    18270      +37     
- Misses         7075     7121      +46     
- Partials       1182     1185       +3     
Impacted Files Coverage Δ
...core/trip/service/NavigationNotificationService.kt 0.00% <0.00%> (ø)
...ui/maps/guidance/junction/api/MapboxJunctionApi.kt 81.48% <ø> (ø)
...vigation/core/internal/dump/HelpDumpInterceptor.kt 5.40% <5.40%> (ø)
...avigation/core/internal/dump/MapboxDumpRegistry.kt 12.50% <12.50%> (ø)
...navigation/core/internal/dump/MapboxDumpHandler.kt 83.33% <83.33%> (ø)
...n/core/internal/dump/MapboxDumpRegistryDelegate.kt 94.11% <94.11%> (ø)
...ion/ui/maps/guidance/junction/JunctionProcessor.kt 85.00% <100.00%> (+1.21%) ⬆️

@kmadsen kmadsen force-pushed the km-update-unit-type-from-command-line branch from 533200d to c9ff633 Compare August 26, 2022 14:29
@kmadsen kmadsen marked this pull request as draft August 26, 2022 23:44
@kmadsen kmadsen changed the title Update distance formatter from command line Add a dumpsys adb interceptor to add command line controls Aug 26, 2022
@kmadsen kmadsen force-pushed the km-update-unit-type-from-command-line branch 5 times, most recently from 562be44 to 4d46bae Compare August 30, 2022 02:01
@kmadsen kmadsen marked this pull request as ready for review August 30, 2022 02:02
@kmadsen kmadsen force-pushed the km-update-unit-type-from-command-line branch 3 times, most recently from ba1097c to 3789f59 Compare August 31, 2022 18:05
@kmadsen kmadsen force-pushed the km-update-unit-type-from-command-line branch 5 times, most recently from ce494df to d22f8dc Compare September 7, 2022 19:20
@kmadsen
Copy link
Contributor Author

kmadsen commented Sep 7, 2022

FIXED: Issue was here #6288 (comment)

This ci/circleci: static-analysis — Your tests failed on CircleCI keeps failing and i don't know why. I tried to SSH into the circleci machine and it passed when I ran it with SSH

EDIT: solution around the internet appears to be a memory issue when searching for the error

https://support.circleci.com/hc/en-us/articles/360021812453-Common-Android-memory-issues
https://docs.gradle.org/current/userguide/gradle_daemon.html#sec:stopping_an_existing_daemon
https://discuss.circleci.com/t/your-build-has-exceeded-the-memory-limit-of-4g-on-1-container/18791
https://stackoverflow.com/questions/37171043/gradle-build-daemon-disappeared-unexpectedly-it-may-have-been-killed-or-may-hav

EDIT2: Trying to disable the daemon or increasing memory still fails.

EDIT3: I'm pretty sure this problem started after rebasing. It was passing before ..

@kmadsen kmadsen force-pushed the km-update-unit-type-from-command-line branch 5 times, most recently from f8b2308 to 8d1d1a8 Compare September 8, 2022 17:23
@kmadsen kmadsen force-pushed the km-update-unit-type-from-command-line branch from f4f9a60 to 10f78c5 Compare September 8, 2022 19:11
@kmadsen kmadsen force-pushed the km-update-unit-type-from-command-line branch from 10f78c5 to e14f29a Compare September 8, 2022 19:51
@kmadsen kmadsen merged commit 656b645 into main Sep 8, 2022
@kmadsen kmadsen deleted the km-update-unit-type-from-command-line branch September 8, 2022 20:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants