mirror of
				https://github.com/f-droid/fdroidserver.git
				synced 2025-11-04 06:30:27 +03:00 
			
		
		
		
	update: do not crash with androguard when working with apps without icons
For example, SpeedoMeterApp.main_1.apk
This commit is contained in:
		
							parent
							
								
									00b334689f
								
							
						
					
					
						commit
						d98d8c2e52
					
				
					 3 changed files with 8 additions and 3 deletions
				
			
		| 
						 | 
				
			
			@ -1223,9 +1223,11 @@ def scan_apk_androguard(apk, apkfile):
 | 
			
		|||
    if apkobject.get_target_sdk_version() is not None:
 | 
			
		||||
        apk['targetSdkVersion'] = apkobject.get_target_sdk_version()
 | 
			
		||||
 | 
			
		||||
    icon_id = int(apkobject.get_element("application", "icon").replace("@", "0x"), 16)
 | 
			
		||||
    icon_name = arsc.get_id(apk['packageName'], icon_id)[1]
 | 
			
		||||
    apk['icons_src'] = _get_apk_icons_src(apkfile, icon_name)
 | 
			
		||||
    icon_id_str = apkobject.get_element("application", "icon")
 | 
			
		||||
    if icon_id_str:
 | 
			
		||||
        icon_id = int(icon_id_str.replace("@", "0x"), 16)
 | 
			
		||||
        icon_name = arsc.get_id(apk['packageName'], icon_id)[1]
 | 
			
		||||
        apk['icons_src'] = _get_apk_icons_src(apkfile, icon_name)
 | 
			
		||||
 | 
			
		||||
    arch_re = re.compile("^lib/(.*)/.*$")
 | 
			
		||||
    arch = set([arch_re.match(file).group(1) for file in apkobject.get_files() if arch_re.match(file)])
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										
											BIN
										
									
								
								tests/SpeedoMeterApp.main_1.apk
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								tests/SpeedoMeterApp.main_1.apk
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| 
						 | 
				
			
			@ -333,6 +333,9 @@ class UpdateTest(unittest.TestCase):
 | 
			
		|||
                                                 '320': 'res/drawable-xhdpi-v4/icon.png',
 | 
			
		||||
                                                 '-1': 'res/drawable-mdpi-v4/icon.png'})
 | 
			
		||||
 | 
			
		||||
        apk_info = fdroidserver.update.scan_apk('SpeedoMeterApp.main_1.apk')
 | 
			
		||||
        self.assertEqual(apk_info['icons_src'], {})
 | 
			
		||||
 | 
			
		||||
    def test_scan_apk_no_sig(self):
 | 
			
		||||
        config = dict()
 | 
			
		||||
        fdroidserver.common.fill_config_defaults(config)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue