From f467f6f99159bd90405fad032761d87a9e9e4f8d Mon Sep 17 00:00:00 2001
From: Marc Bonnici <marc.bonnici@arm.com>
Date: Thu, 8 Dec 2016 15:55:18 +0000
Subject: [PATCH] AndroidDevice: Added method to retrive primary abi of
 installed package

Tries to retireve the primary abi of a currently installed package on
device.
---
 wlauto/common/android/device.py | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/wlauto/common/android/device.py b/wlauto/common/android/device.py
index 31362173..8feb184d 100644
--- a/wlauto/common/android/device.py
+++ b/wlauto/common/android/device.py
@@ -262,6 +262,24 @@ class AndroidDevice(BaseLinuxDevice):  # pylint: disable=W0223
                 return line.split('=', 1)[1]
         return None
 
+    def get_installed_package_abi(self, package):
+        """
+        Returns the primary abi of the specified package if it is installed
+        on the device, or ``None`` otherwise.
+        """
+        output = self.execute('dumpsys package {}'.format(package))
+        val = None
+        for line in convert_new_lines(output).split('\n'):
+            if 'primaryCpuAbi' in line:
+                val = line.split('=', 1)[1]
+                break
+        if val == 'null':
+            return None
+        for abi, architectures in ABI_MAP.iteritems():
+            if val in architectures:
+                return abi
+        return val
+
     def list_packages(self):
         """
         List packages installed on the device.