mirror of
				https://github.com/ARM-software/devlib.git
				synced 2025-11-04 07:51:21 +00:00 
			
		
		
		
	utils.android.ApkInfo: Add reading activity names
Add an activities pseudo-attribute to the ApkInfo class that retrieves the names of the activities (_i.e._ entry points) of the APK. To keep backward compatibility, these are retrieved the first time the attribute is being accessed.
This commit is contained in:
		
				
					committed by
					
						
						Marc Bonnici
					
				
			
			
				
	
			
			
			
						parent
						
							7e0e6e8706
						
					
				
				
					commit
					2b6cb264cf
				
			@@ -132,6 +132,7 @@ class ApkInfo(object):
 | 
			
		||||
    version_regex = re.compile(r"name='(?P<name>[^']+)' versionCode='(?P<vcode>[^']+)' versionName='(?P<vname>[^']+)'")
 | 
			
		||||
    name_regex = re.compile(r"name='(?P<name>[^']+)'")
 | 
			
		||||
    permission_regex = re.compile(r"name='(?P<permission>[^']+)'")
 | 
			
		||||
    activity_regex = re.compile(r'\s*A:\s*android:name\(0x\d+\)=".(?P<name>\w+)"')
 | 
			
		||||
 | 
			
		||||
    def __init__(self, path=None):
 | 
			
		||||
        self.path = path
 | 
			
		||||
@@ -180,6 +181,18 @@ class ApkInfo(object):
 | 
			
		||||
            else:
 | 
			
		||||
                pass  # not interested
 | 
			
		||||
 | 
			
		||||
        self._apk_path = apk_path
 | 
			
		||||
        self._activities = None
 | 
			
		||||
 | 
			
		||||
    @property
 | 
			
		||||
    def activities(self):
 | 
			
		||||
        if self._activities is None:
 | 
			
		||||
            cmd = [aapt, 'dump', 'xmltree', self._apk_path,
 | 
			
		||||
                   'AndroidManifest.xml']
 | 
			
		||||
            matched_activities = self.activity_regex.finditer(self._run(cmd))
 | 
			
		||||
            self._activities = [m.group('name') for m in matched_activities]
 | 
			
		||||
        return self._activities
 | 
			
		||||
 | 
			
		||||
    def _run(self, command):
 | 
			
		||||
        logger.debug(' '.join(command))
 | 
			
		||||
        try:
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user