Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7ddc70dd authored by weichinweng's avatar weichinweng
Browse files

Hearing Aid Dump Audio Tool: Add No Start Cmd feature

When the HCI Snoop logs wraparound, the Hearing Aid Audio Control
Command "Start" is lost. For the case, we can enable No Start Cmd
feature to set a fake "Start" to extract audio data.

Bug: 127745964
Test: ./dump_hearingaid_audio.py -c1 1 -c2 3 -ns true btsnoop_hci.log
Change-Id: Id7f67da0d5476faf38352ab57339fed8e358bac6
parent 95c949f4
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -443,6 +443,11 @@ def set_config():
  argv_parser.add_argument("-c2", "--connection-handle2",
                           help="set a fake connection handle 2 to capture \
                           audio dump.", dest="connection_handle2", type=int)
  argv_parser.add_argument("-ns", "--no-start", help="No audio 'Start' cmd is \
                           needed before extracting audio data.",
                           dest="no_start", default="False")
  argv_parser.add_argument("-dc", "--default-codec", help="set a default \
                           codec.", dest="codec", default="G722")
  argv_parser.add_argument("-a", "--attr-handle",
                           help="force to select audio control attr handle.",
                           dest="audio_control_attr_handle", type=int)
@@ -458,17 +463,33 @@ def set_config():
                          connection_handle2")
        exit(1)

  if not (arg.no_start.lower() == "true" or arg.no_start.lower() == "false"):
    argv_parser.error("-ns/--no-start arg is invalid, it should be true/false.")
    exit(1)

  if arg.connection_handle1 is not None:
    fake_name = "ConnectionHandle" + str(arg.connection_handle1)
    update_audio_data("", "", PEER_ADDRESS, fake_name)
    update_audio_data(PEER_ADDRESS, fake_name, CONNECTION_HANDLE,
                      arg.connection_handle1)
    if arg.no_start.lower() == "true":
      update_audio_data(PEER_ADDRESS, fake_name, START, True)
      update_audio_data(PEER_ADDRESS, fake_name, TIMESTAMP, "Unknown")
      update_audio_data(PEER_ADDRESS, fake_name, CODEC, arg.codec)
      update_audio_data(PEER_ADDRESS, fake_name, SAMPLE_RATE, "Unknown")
      update_audio_data(PEER_ADDRESS, fake_name, AUDIO_TYPE, "Unknown")

  if arg.connection_handle2 is not None:
    fake_name = "ConnectionHandle" + str(arg.connection_handle2)
    update_audio_data("", "", PEER_ADDRESS, fake_name)
    update_audio_data(PEER_ADDRESS, fake_name, CONNECTION_HANDLE,
                      arg.connection_handle2)
    if arg.no_start.lower() == "true":
      update_audio_data(PEER_ADDRESS, fake_name, START, True)
      update_audio_data(PEER_ADDRESS, fake_name, TIMESTAMP, "Unknown")
      update_audio_data(PEER_ADDRESS, fake_name, CODEC, arg.codec)
      update_audio_data(PEER_ADDRESS, fake_name, SAMPLE_RATE, "Unknown")
      update_audio_data(PEER_ADDRESS, fake_name, AUDIO_TYPE, "Unknown")

  if arg.audio_control_attr_handle is not None:
    global force_audio_control_attr_handle