Skip to content

Commit

Permalink
Update shell.py
Browse files Browse the repository at this point in the history
  • Loading branch information
codeskyblue committed May 10, 2024
1 parent f3bd4b9 commit 6aaec20
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions adbutils/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,12 @@ def switch_screen(self, enable: bool):
return self.keyevent(224 if enable else 223)

@property
def brightness_value(self):
def brightness_value(self) -> int:
"""
Return screen brightness values
:return: brightness value
eg: print(d.brightness_value) output:128
Return screen brightness value, [0, 255]
Examples:
print(d.brightness_value) output:128
"""
value = self.shell('settings get system screen_brightness')
return int(value.strip())

Check warning on line 87 in adbutils/shell.py

View check run for this annotation

Codecov / codecov/patch

adbutils/shell.py#L86-L87

Added lines #L86 - L87 were not covered by tests
Expand All @@ -96,23 +97,27 @@ def brightness_value(self, value: int):
raise ValueError("Brightness value must be an integer")

Check warning on line 97 in adbutils/shell.py

View check run for this annotation

Codecov / codecov/patch

adbutils/shell.py#L97

Added line #L97 was not covered by tests
if not 0 <= value <= 255:
raise ValueError("Brightness value must be between 0 and 255")
self.shell(f"settings put system screen_brightness {str(value)}")
self.shell(f"settings put system screen_brightness {value}")

Check warning on line 100 in adbutils/shell.py

View check run for this annotation

Codecov / codecov/patch

adbutils/shell.py#L99-L100

Added lines #L99 - L100 were not covered by tests

@property
def brightness_mode(self) -> BrightnessMode:
"""
Return screen brightness mode
:return: BrightnessMode.AUTO or BrightnessMode.MANUAL
"""
value = int(self.shell('settings get system screen_brightness_mode').strip())
value = int(self.shell('settings get system screen_brightness_mode'))
return BrightnessMode(value)

Check warning on line 109 in adbutils/shell.py

View check run for this annotation

Codecov / codecov/patch

adbutils/shell.py#L108-L109

Added lines #L108 - L109 were not covered by tests

@brightness_mode.setter
def brightness_mode(self, mode: BrightnessMode):
"""
Set screen brightness mode
:param mode: BrightnessMode.AUTO or BrightnessMode.MANUAL
eg: d.brightness_mode = BrightnessMode.AUTO
Args:
mode: BrightnessMode.AUTO or BrightnessMode.MANUAL
Example:
d.brightness_mode = BrightnessMode.AUTO
"""
if isinstance(mode, BrightnessMode):
self.shell(f"settings put system screen_brightness_mode {mode.value}")

Check warning on line 123 in adbutils/shell.py

View check run for this annotation

Codecov / codecov/patch

adbutils/shell.py#L123

Added line #L123 was not covered by tests
Expand Down

0 comments on commit 6aaec20

Please sign in to comment.