Skip to content

Commit

Permalink
add back package_info
Browse files Browse the repository at this point in the history
  • Loading branch information
codeskyblue committed Apr 8, 2024
1 parent dfaf340 commit 488b13b
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ $ adb devices

### Remove
- current_app removed, use app_current instead
- package_info removed, use app_info instead
- package_info is going to remove, use app_info instead

### Add
- add volume_up, volume_down, volume_mute
Expand Down
25 changes: 25 additions & 0 deletions adbutils/_deprecated.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""Created on Mon Apr 08 2024 12:21:30 by codeskyblue
"""

import abc
import dataclasses
from typing import Optional
from adbutils._proto import AppInfo


class AbstracctDevice(abc.ABC):
@abc.abstractmethod
def app_info(self, package_name: str) -> Optional[AppInfo]:
pass


class DeprecatedExtension(AbstracctDevice):
def package_info(self, package_name: str) -> Optional[dict]:
"""deprecated method, use app_info instead."""
info = self.app_info(package_name)
if info:
return dataclasses.asdict(info)
return None
2 changes: 2 additions & 0 deletions adbutils/_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from typing import Optional, Union


from adbutils._deprecated import DeprecatedExtension
from adbutils.install import InstallExtension
from adbutils.screenrecord import ScreenrecordExtension
from adbutils.screenshot import ScreenshotExtesion
Expand Down Expand Up @@ -450,6 +451,7 @@ class AdbDevice(
ScreenrecordExtension,
ScreenshotExtesion,
InstallExtension,
DeprecatedExtension,
):
"""provide custom functions for some complex operations"""

Expand Down
2 changes: 1 addition & 1 deletion adbutils/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ def app_stop(self, package_name: str):

def app_clear(self, package_name: str):
self.shell(["pm", "clear", package_name])

def app_info(self, package_name: str) -> Optional[AppInfo]:
"""
Get app info
Expand Down
1 change: 0 additions & 1 deletion test_real_device/test_deprecated.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from adbutils import AdbDevice, adb


@pytest.mark.skip("package_info is removed")
def test_package_info(device: AdbDevice):
pinfo = device.app_current()
pinfo = device.package_info(pinfo.package)
Expand Down

0 comments on commit 488b13b

Please sign in to comment.