Refactor cpuAbis to compat/SupportedArchitectures
Changes: * Use HashSet instead of ArrayList * Print all the abis on Log.d instead of just the first one * Get rid of lintian warnings
This commit is contained in:
		
							parent
							
								
									61ba6d52d0
								
							
						
					
					
						commit
						f1c7846605
					
				| @ -52,6 +52,7 @@ import android.util.Log; | |||||||
| 
 | 
 | ||||||
| import org.fdroid.fdroid.compat.Compatibility; | import org.fdroid.fdroid.compat.Compatibility; | ||||||
| import org.fdroid.fdroid.compat.ContextCompat; | import org.fdroid.fdroid.compat.ContextCompat; | ||||||
|  | import org.fdroid.fdroid.compat.SupportedArchitectures; | ||||||
| import org.fdroid.fdroid.data.DBHelper; | import org.fdroid.fdroid.data.DBHelper; | ||||||
| 
 | 
 | ||||||
| public class DB { | public class DB { | ||||||
| @ -321,7 +322,8 @@ public class DB { | |||||||
|         private static class CompatibilityChecker extends Compatibility { |         private static class CompatibilityChecker extends Compatibility { | ||||||
| 
 | 
 | ||||||
|             private HashSet<String> features; |             private HashSet<String> features; | ||||||
|             private List<String> cpuAbis; |             private HashSet<String> cpuAbis; | ||||||
|  |             private String cpuAbisDesc; | ||||||
|             private boolean ignoreTouchscreen; |             private boolean ignoreTouchscreen; | ||||||
| 
 | 
 | ||||||
|             //@SuppressLint("NewApi") |             //@SuppressLint("NewApi") | ||||||
| @ -344,11 +346,17 @@ public class DB { | |||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
| 
 | 
 | ||||||
|                 cpuAbis = new ArrayList<String>(2); |                 cpuAbis = SupportedArchitectures.getAbis(); | ||||||
|                 cpuAbis.add(android.os.Build.CPU_ABI); | 
 | ||||||
|                 if (hasApi(8)) { |                 StringBuilder builder = new StringBuilder(); | ||||||
|                     cpuAbis.add(android.os.Build.CPU_ABI2); |                 boolean first = true; | ||||||
|  |                 for (String abi : cpuAbis) { | ||||||
|  |                     if (first) first = false; | ||||||
|  |                     else builder.append(", "); | ||||||
|  |                     builder.append(abi); | ||||||
|                 } |                 } | ||||||
|  |                 cpuAbisDesc = builder.toString(); | ||||||
|  |                 builder = null; | ||||||
| 
 | 
 | ||||||
|                 Log.d("FDroid", logMsg.toString()); |                 Log.d("FDroid", logMsg.toString()); | ||||||
|             } |             } | ||||||
| @ -382,7 +390,7 @@ public class DB { | |||||||
|                 if (!compatibleApi(apk.nativecode)) { |                 if (!compatibleApi(apk.nativecode)) { | ||||||
|                     Log.d("FDroid", apk.id + " vercode " + apk.vercode |                     Log.d("FDroid", apk.id + " vercode " + apk.vercode | ||||||
|                             + " only supports " + CommaSeparatedList.str(apk.nativecode) |                             + " only supports " + CommaSeparatedList.str(apk.nativecode) | ||||||
|                             + " while your architecture is " + cpuAbis.get(0)); |                             + " while your architectures are " + cpuAbisDesc); | ||||||
|                     return false; |                     return false; | ||||||
|                 } |                 } | ||||||
|                 return true; |                 return true; | ||||||
|  | |||||||
							
								
								
									
										30
									
								
								src/org/fdroid/fdroid/compat/SupportedArchitectures.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								src/org/fdroid/fdroid/compat/SupportedArchitectures.java
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,30 @@ | |||||||
|  | package org.fdroid.fdroid.compat; | ||||||
|  | 
 | ||||||
|  | import java.util.HashSet; | ||||||
|  | 
 | ||||||
|  | import android.annotation.TargetApi; | ||||||
|  | import android.util.Log; | ||||||
|  | import android.os.Build; | ||||||
|  | 
 | ||||||
|  | public class SupportedArchitectures extends Compatibility { | ||||||
|  | 
 | ||||||
|  |     private static HashSet<String> getOneAbi() { | ||||||
|  |         HashSet<String> abis = new HashSet<String>(1); | ||||||
|  |         abis.add(Build.CPU_ABI); | ||||||
|  |         return abis; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     @TargetApi(8) | ||||||
|  |     private static HashSet<String> getTwoAbis() { | ||||||
|  |         HashSet<String> abis = new HashSet<String>(2); | ||||||
|  |         abis.add(Build.CPU_ABI); | ||||||
|  |         abis.add(Build.CPU_ABI2); | ||||||
|  |         return abis; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public static HashSet<String> getAbis() { | ||||||
|  |         if (hasApi(8)) return getTwoAbis(); | ||||||
|  |         return getOneAbi(); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | } | ||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Daniel Martí
						Daniel Martí