Closed Bug 1190701 Opened 9 years ago Closed 6 years ago

[mozdevice] implementation of ADBAndroidMixin.is_app_installed() is ambiguous

Categories

(Testing :: Mozbase, defect)

42 Branch
defect
Not set
normal

Tracking

(firefox64 fixed)

RESOLVED FIXED
mozilla64
Tracking Status
firefox64 --- fixed

People

(Reporter: KK, Assigned: egao)

Details

Attachments

(1 file)

::: testing/mozbase/mozdevice/mozdevice/adb_android.py > def is_app_installed(self, app_name, timeout=None): > """Returns True if an app is installed on the device. > > :param app_name: string containing the name of the app to be > checked. > :param timeout: optional integer specifying the maximum time in > seconds for any spawned adb process to complete before > throwing an ADBTimeoutError. > This timeout is per adb call. The total time spent > may exceed this value. If it is not specified, the value > set in the ADB constructor is used. > :raises: * ADBTimeoutError > * ADBError > > """ > pm_error_string = 'Error: Could not access the Package Manager' > data = self.shell_output("pm list package %s" % app_name, timeout=timeout) > if pm_error_string in data: > raise ADBError(pm_error_string) > if app_name not in data: > return False > return True Take my case for instance, I've installed org.mozilla.fennec_fdroid on my device, so when I execute is_app_installed("org.mozilla.fennec") it return True. Here's my two solution to fix it: 1. we can return True only when app_name == data 2. we can add argument to is_app_installed specifying that we want to find exactly the app_name But these changes will affect projects that use this function, not sure if they are appropriate solutions.
- added optional argument for performing exact matches, defaulting to False (maintaining existing behavior) - if match_exact is desired, the exact package name as appears in adb shell::pm list packages call must be specified.
Comment on attachment 9013393 [details] Bug 1190701 - make ADBAndroidMixin.is_app_installed() unambiguous r?gbrown,bc Geoff Brown [:gbrown] has approved the revision.
Attachment #9013393 - Flags: review+
Assignee: nobody → egao
After an r+, changes were made such that ambiguous behavior has been removed. The following are test runs on try for code blocks that should exercise ADBDevice.is_app_installed() code blocks: https://treeherder.mozilla.org/#/jobs?repo=try&revision=f22dc13d1e832dce3502ab122d19d70605adee42 Additionally, raptor was run locally and tests passed.
Attachment #9013393 - Attachment description: Bug 1190701 - [mozdevice] implementation of ADBAndroidMixin.is_app_installed() is ambiguous r?gbrown,bc → Bug 1190701 - make ADBAndroidMixin.is_app_installed() unambiguous r?gbrown,bc
Pushed by gbrown@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/1c7f3cf86aed make ADBAndroidMixin.is_app_installed() unambiguous r=bc,gbrown
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla64
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: