Make CommaSeparatedList.make() also take String[]

This commit is contained in:
Daniel Martí 2015-04-30 20:51:19 +02:00
parent 7b4cee35c7
commit 45ab80bb29
4 changed files with 22 additions and 18 deletions

View File

@ -480,9 +480,9 @@ public class UpdateService extends IntentService implements ProgressListener {
* in order to see if, and why an apk is not compatible.
*/
private static void calcApkCompatibilityFlags(Context context, List<Apk> apks) {
CompatibilityChecker checker = new CompatibilityChecker(context);
for (Apk apk : apks) {
List<String> reasons = checker.getIncompatibleReasons(apk);
final CompatibilityChecker checker = new CompatibilityChecker(context);
for (final Apk apk : apks) {
final List<String> reasons = checker.getIncompatibleReasons(apk);
if (reasons.size() > 0) {
apk.compatible = false;
apk.incompatible_reasons = Utils.CommaSeparatedList.make(reasons);

View File

@ -430,6 +430,19 @@ public final class Utils {
return new CommaSeparatedList(sb.toString());
}
public static CommaSeparatedList make(String[] list) {
if (list == null || list.length == 0)
return null;
StringBuilder sb = new StringBuilder();
for (int i = 0; i < list.length; i++) {
if (i > 0) {
sb.append(',');
}
sb.append(list[i]);
}
return new CommaSeparatedList(sb.toString());
}
public static CommaSeparatedList make(String list) {
if (list == null || list.length() == 0)
return null;

View File

@ -262,27 +262,18 @@ public class App extends ValueObject implements Comparable<App> {
apk.minSdkVersion = Utils.getMinSdkVersion(context, packageName);
apk.id = this.id;
apk.installedFile = apkFile;
if (packageInfo.requestedPermissions == null)
apk.permissions = null;
else
apk.permissions = Utils.CommaSeparatedList.make(
Arrays.asList(packageInfo.requestedPermissions));
apk.permissions = Utils.CommaSeparatedList.make(packageInfo.requestedPermissions);
apk.apkName = apk.id + "_" + apk.vercode + ".apk";
final FeatureInfo[] features = packageInfo.reqFeatures;
if (features != null && features.length > 0) {
final List<String> featureNames = new ArrayList<>(features.length);
for (FeatureInfo feature : features) {
featureNames.add(feature.name);
final String[] featureNames = new String[features.length];
for (int i = 0; i < features.length; i++) {
featureNames[i] = features[i].name;
}
apk.features = Utils.CommaSeparatedList.make(featureNames);
}
// Signature[] sigs = pkgInfo.signatures;
byte[] rawCertBytes;
final JarFile apkJar = new JarFile(apkFile);

View File

@ -91,8 +91,8 @@ public class AppProvider extends FDroidProvider {
final ContentResolver resolver = context.getContentResolver();
final Uri uri = getContentUri();
final String[] projection = { DataColumns.CATEGORIES };
Cursor cursor = resolver.query(uri, projection, null, null, null);
Set<String> categorySet = new HashSet<>();
final Cursor cursor = resolver.query(uri, projection, null, null, null);
final Set<String> categorySet = new HashSet<>();
if (cursor != null) {
if (cursor.getCount() > 0) {
cursor.moveToFirst();