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

Update get_battery_level_and_temperature() #4300

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/clusterfuzz/_internal/platforms/android/battery.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def get_battery_level_and_temperature():
output = adb.run_shell_command(['dumpsys', 'battery'])

# Get battery level.
m_battery_level = re.match(r'.*level: (\d+).*', output, re.DOTALL)
m_battery_level = re.match(r'.*\n[\t ]*level: (\d+).*', output, re.DOTALL)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you write a simple unit test for this, so it becomes more explicit what kind of input we are expecting here? As someone who is not dealing with android on an everyday basis, it is hard to understand:

  • Why the previous code broke
  • Why this change solves the above

if not m_battery_level:
logs.error('Error occurred while getting battery status.')
return None
Expand Down
Loading