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

RESOLVED FIXED in Firefox 64

Status

defect
RESOLVED FIXED
4 years ago
8 months ago

People

(Reporter: KK, Assigned: egao)

Tracking

42 Branch
mozilla64
Points:
---

Firefox Tracking Flags

(firefox64 fixed)

Details

Attachments

(1 attachment)

Reporter

Description

4 years ago
::: 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.
Assignee

Comment 2

9 months ago
- 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

Updated

9 months ago
Assignee: nobody → egao
Assignee

Comment 4

9 months ago
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

Comment 5

9 months ago
Pushed by gbrown@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/1c7f3cf86aed
make ADBAndroidMixin.is_app_installed() unambiguous r=bc,gbrown

Comment 6

9 months ago
bugherder
https://hg.mozilla.org/mozilla-central/rev/1c7f3cf86aed
Status: NEW → RESOLVED
Closed: 9 months ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla64
You need to log in before you can comment on or make changes to this bug.