Renamed generic sounding methods to be more specific.
Originally, I hoped that the arguments a method took would help enough to differentiate the intent of that method. This was the case for methods such as `getContentUri()` and `find()`. However they are a little confusing to work with, so this change renames a bunch of methods to be more specific. In addition, it makes some renames from app -> package which will help with the upcoming change to add a `package` table to the database.
This commit is contained in:
		
							parent
							
								
									0362ca7f75
								
							
						
					
					
						commit
						df0b162512
					
				@ -856,7 +856,7 @@ public class AppDetails extends AppCompatActivity {
 | 
			
		||||
            case INSTALL:
 | 
			
		||||
                // Note that this handles updating as well as installing.
 | 
			
		||||
                if (app.suggestedVersionCode > 0) {
 | 
			
		||||
                    final Apk apkToInstall = ApkProvider.Helper.find(this, app.packageName, app.suggestedVersionCode);
 | 
			
		||||
                    final Apk apkToInstall = ApkProvider.Helper.findApkFromAnyRepo(this, app.packageName, app.suggestedVersionCode);
 | 
			
		||||
                    install(apkToInstall);
 | 
			
		||||
                }
 | 
			
		||||
                return true;
 | 
			
		||||
@ -1006,7 +1006,7 @@ public class AppDetails extends AppCompatActivity {
 | 
			
		||||
            case REQUEST_PERMISSION_DIALOG:
 | 
			
		||||
                if (resultCode == Activity.RESULT_OK) {
 | 
			
		||||
                    Uri uri = data.getData();
 | 
			
		||||
                    Apk apk = ApkProvider.Helper.find(this, uri, Schema.ApkTable.Cols.ALL);
 | 
			
		||||
                    Apk apk = ApkProvider.Helper.findByUri(this, uri, Schema.ApkTable.Cols.ALL);
 | 
			
		||||
                    startInstall(apk);
 | 
			
		||||
                }
 | 
			
		||||
                break;
 | 
			
		||||
@ -1624,7 +1624,7 @@ public class AppDetails extends AppCompatActivity {
 | 
			
		||||
                App app = appDetails.getApp();
 | 
			
		||||
                AppDetails activity = (AppDetails) getActivity();
 | 
			
		||||
                if (updateWanted && app.suggestedVersionCode > 0) {
 | 
			
		||||
                    Apk apkToInstall = ApkProvider.Helper.find(activity, app.packageName, app.suggestedVersionCode);
 | 
			
		||||
                    Apk apkToInstall = ApkProvider.Helper.findApkFromAnyRepo(activity, app.packageName, app.suggestedVersionCode);
 | 
			
		||||
                    activity.install(apkToInstall);
 | 
			
		||||
                    return;
 | 
			
		||||
                }
 | 
			
		||||
@ -1640,7 +1640,7 @@ public class AppDetails extends AppCompatActivity {
 | 
			
		||||
                    // If not installed, install
 | 
			
		||||
                    btMain.setEnabled(false);
 | 
			
		||||
                    btMain.setText(R.string.system_install_installing);
 | 
			
		||||
                    final Apk apkToInstall = ApkProvider.Helper.find(activity, app.packageName, app.suggestedVersionCode);
 | 
			
		||||
                    final Apk apkToInstall = ApkProvider.Helper.findApkFromAnyRepo(activity, app.packageName, app.suggestedVersionCode);
 | 
			
		||||
                    activity.install(apkToInstall);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
@ -473,7 +473,7 @@ public class RepoUpdater {
 | 
			
		||||
                if (packageInfo != null && versionCode == packageInfo.versionCode) {
 | 
			
		||||
                    Utils.debugLog(TAG, repoPushRequest + " already installed, ignoring");
 | 
			
		||||
                } else {
 | 
			
		||||
                    Apk apk = ApkProvider.Helper.find(context, packageName, versionCode);
 | 
			
		||||
                    Apk apk = ApkProvider.Helper.findApkFromAnyRepo(context, packageName, versionCode);
 | 
			
		||||
                    InstallManagerService.queue(context, app, apk);
 | 
			
		||||
                }
 | 
			
		||||
            } else if (RepoPushRequest.UNINSTALL.equals(repoPushRequest.request)) {
 | 
			
		||||
@ -483,7 +483,7 @@ public class RepoUpdater {
 | 
			
		||||
                }
 | 
			
		||||
                if (repoPushRequest.versionCode == null
 | 
			
		||||
                        || repoPushRequest.versionCode == packageInfo.versionCode) {
 | 
			
		||||
                    Apk apk = ApkProvider.Helper.find(context, repoPushRequest.packageName,
 | 
			
		||||
                    Apk apk = ApkProvider.Helper.findApkFromAnyRepo(context, repoPushRequest.packageName,
 | 
			
		||||
                            packageInfo.versionCode);
 | 
			
		||||
                    InstallerService.uninstall(context, apk);
 | 
			
		||||
                } else {
 | 
			
		||||
 | 
			
		||||
@ -468,7 +468,7 @@ public class UpdateService extends IntentService {
 | 
			
		||||
            cursor.moveToFirst();
 | 
			
		||||
            for (int i = 0; i < cursor.getCount(); i++) {
 | 
			
		||||
                App app = new App(cursor);
 | 
			
		||||
                Apk apk = ApkProvider.Helper.find(this, app.packageName, app.suggestedVersionCode);
 | 
			
		||||
                Apk apk = ApkProvider.Helper.findApkFromAnyRepo(this, app.packageName, app.suggestedVersionCode);
 | 
			
		||||
                InstallManagerService.queue(this, app, apk);
 | 
			
		||||
                cursor.moveToNext();
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
@ -36,7 +36,7 @@ public class ApkProvider extends FDroidProvider {
 | 
			
		||||
 | 
			
		||||
        public static void update(Context context, Apk apk) {
 | 
			
		||||
            ContentResolver resolver = context.getContentResolver();
 | 
			
		||||
            Uri uri = getContentUri(apk.packageName, apk.versionCode);
 | 
			
		||||
            Uri uri = getApkFromAnyRepoUri(apk.packageName, apk.versionCode);
 | 
			
		||||
            resolver.update(uri, apk.toContentValues(), null, null);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@ -62,8 +62,8 @@ public class ApkProvider extends FDroidProvider {
 | 
			
		||||
            return resolver.delete(uri, null, null);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static Apk find(Context context, String packageName, int versionCode) {
 | 
			
		||||
            return find(context, packageName, versionCode, Cols.ALL);
 | 
			
		||||
        public static Apk findApkFromAnyRepo(Context context, String packageName, int versionCode) {
 | 
			
		||||
            return findApkFromAnyRepo(context, packageName, versionCode, Cols.ALL);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /**
 | 
			
		||||
@ -77,12 +77,12 @@ public class ApkProvider extends FDroidProvider {
 | 
			
		||||
            return cursorToList(cursor);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static Apk find(Context context, String packageName, int versionCode, String[] projection) {
 | 
			
		||||
            final Uri uri = getContentUri(packageName, versionCode);
 | 
			
		||||
            return find(context, uri, projection);
 | 
			
		||||
        public static Apk findApkFromAnyRepo(Context context, String packageName, int versionCode, String[] projection) {
 | 
			
		||||
            final Uri uri = getApkFromAnyRepoUri(packageName, versionCode);
 | 
			
		||||
            return findByUri(context, uri, projection);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static Apk find(Context context, Uri uri, String[] projection) {
 | 
			
		||||
        public static Apk findByUri(Context context, Uri uri, String[] projection) {
 | 
			
		||||
            ContentResolver resolver = context.getContentResolver();
 | 
			
		||||
            Cursor cursor = resolver.query(uri, projection, null, null, null);
 | 
			
		||||
            Apk apk = null;
 | 
			
		||||
@ -165,8 +165,8 @@ public class ApkProvider extends FDroidProvider {
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private static final int CODE_APP = CODE_SINGLE + 1;
 | 
			
		||||
    private static final int CODE_REPO = CODE_APP + 1;
 | 
			
		||||
    private static final int CODE_PACKAGE = CODE_SINGLE + 1;
 | 
			
		||||
    private static final int CODE_REPO = CODE_PACKAGE + 1;
 | 
			
		||||
    private static final int CODE_APKS = CODE_REPO + 1;
 | 
			
		||||
    private static final int CODE_REPO_APPS = CODE_APKS + 1;
 | 
			
		||||
    protected static final int CODE_REPO_APK = CODE_REPO_APPS + 1;
 | 
			
		||||
@ -184,17 +184,17 @@ public class ApkProvider extends FDroidProvider {
 | 
			
		||||
    private static final UriMatcher MATCHER = new UriMatcher(-1);
 | 
			
		||||
 | 
			
		||||
    private static final Map<String, String> REPO_FIELDS = new HashMap<>();
 | 
			
		||||
    private static final Map<String, String> APP_FIELDS = new HashMap<>();
 | 
			
		||||
    private static final Map<String, String> PACKAGE_FIELDS = new HashMap<>();
 | 
			
		||||
 | 
			
		||||
    static {
 | 
			
		||||
        REPO_FIELDS.put(Cols.Repo.VERSION, RepoTable.Cols.VERSION);
 | 
			
		||||
        REPO_FIELDS.put(Cols.Repo.ADDRESS, RepoTable.Cols.ADDRESS);
 | 
			
		||||
        APP_FIELDS.put(Cols.App.PACKAGE_NAME, AppMetadataTable.Cols.PACKAGE_NAME);
 | 
			
		||||
        PACKAGE_FIELDS.put(Cols.App.PACKAGE_NAME, AppMetadataTable.Cols.PACKAGE_NAME);
 | 
			
		||||
 | 
			
		||||
        MATCHER.addURI(getAuthority(), PATH_REPO + "/#", CODE_REPO);
 | 
			
		||||
        MATCHER.addURI(getAuthority(), PATH_APK + "/#/*", CODE_SINGLE);
 | 
			
		||||
        MATCHER.addURI(getAuthority(), PATH_APKS + "/*", CODE_APKS);
 | 
			
		||||
        MATCHER.addURI(getAuthority(), PATH_APP + "/*", CODE_APP);
 | 
			
		||||
        MATCHER.addURI(getAuthority(), PATH_APP + "/*", CODE_PACKAGE);
 | 
			
		||||
        MATCHER.addURI(getAuthority(), PATH_REPO_APPS + "/#/*", CODE_REPO_APPS);
 | 
			
		||||
        MATCHER.addURI(getAuthority(), PATH_REPO_APK + "/#/*", CODE_REPO_APK);
 | 
			
		||||
        MATCHER.addURI(getAuthority(), PATH_APK_ROW_ID + "/#", CODE_APK_ROW_ID);
 | 
			
		||||
@ -232,11 +232,11 @@ public class ApkProvider extends FDroidProvider {
 | 
			
		||||
            .build();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static Uri getContentUri(Apk apk) {
 | 
			
		||||
        return getContentUri(apk.packageName, apk.versionCode);
 | 
			
		||||
    public static Uri getApkFromAnyRepoUri(Apk apk) {
 | 
			
		||||
        return getApkFromAnyRepoUri(apk.packageName, apk.versionCode);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static Uri getContentUri(String packageName, int versionCode) {
 | 
			
		||||
    public static Uri getApkFromAnyRepoUri(String packageName, int versionCode) {
 | 
			
		||||
        return getContentUri()
 | 
			
		||||
            .buildUpon()
 | 
			
		||||
            .appendPath(PATH_APK)
 | 
			
		||||
@ -315,8 +315,8 @@ public class ApkProvider extends FDroidProvider {
 | 
			
		||||
 | 
			
		||||
        @Override
 | 
			
		||||
        protected String getRequiredTables() {
 | 
			
		||||
            final String apk  = getTableName();
 | 
			
		||||
            final String app  = getAppTableName();
 | 
			
		||||
            final String apk = getTableName();
 | 
			
		||||
            final String app = getAppTableName();
 | 
			
		||||
 | 
			
		||||
            return apk + " AS apk " +
 | 
			
		||||
                " LEFT JOIN " + app + " AS app ON (app." + AppMetadataTable.Cols.ROW_ID + " = apk." + Cols.APP_ID + ")";
 | 
			
		||||
@ -324,8 +324,8 @@ public class ApkProvider extends FDroidProvider {
 | 
			
		||||
 | 
			
		||||
        @Override
 | 
			
		||||
        public void addField(String field) {
 | 
			
		||||
            if (APP_FIELDS.containsKey(field)) {
 | 
			
		||||
                addAppField(APP_FIELDS.get(field), field);
 | 
			
		||||
            if (PACKAGE_FIELDS.containsKey(field)) {
 | 
			
		||||
                addPackageField(PACKAGE_FIELDS.get(field), field);
 | 
			
		||||
            } else if (REPO_FIELDS.containsKey(field)) {
 | 
			
		||||
                addRepoField(REPO_FIELDS.get(field), field);
 | 
			
		||||
            } else if (field.equals(Cols._ID)) {
 | 
			
		||||
@ -339,7 +339,7 @@ public class ApkProvider extends FDroidProvider {
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void addAppField(String field, String alias) {
 | 
			
		||||
        private void addPackageField(String field, String alias) {
 | 
			
		||||
            appendField(field, "app", alias);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@ -353,22 +353,22 @@ public class ApkProvider extends FDroidProvider {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private QuerySelection queryApp(String packageName) {
 | 
			
		||||
        return queryApp(packageName, true);
 | 
			
		||||
    private QuerySelection queryPackage(String packageName) {
 | 
			
		||||
        return queryPackage(packageName, true);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private QuerySelection queryApp(String packageName, boolean includeTableAlias) {
 | 
			
		||||
    private QuerySelection queryPackage(String packageName, boolean includeTableAlias) {
 | 
			
		||||
        String alias = includeTableAlias ? "apk." : "";
 | 
			
		||||
        final String selection = alias + Cols.APP_ID + " = (" + getAppIdFromPackageNameQuery() + ")";
 | 
			
		||||
        final String[] args = {packageName};
 | 
			
		||||
        return new QuerySelection(selection, args);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private QuerySelection querySingle(Uri uri) {
 | 
			
		||||
        return querySingle(uri, true);
 | 
			
		||||
    private QuerySelection querySingleFromAnyRepo(Uri uri) {
 | 
			
		||||
        return querySingleFromAnyRepo(uri, true);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private QuerySelection querySingle(Uri uri, boolean includeAlias) {
 | 
			
		||||
    private QuerySelection querySingleFromAnyRepo(Uri uri, boolean includeAlias) {
 | 
			
		||||
        String alias = includeAlias ? "apk." : "";
 | 
			
		||||
        final String selection = alias + Cols.VERSION_CODE + " = ? and " + alias + Cols.APP_ID + " = (" + getAppIdFromPackageNameQuery() + ")";
 | 
			
		||||
        final String[] args = {
 | 
			
		||||
@ -403,7 +403,7 @@ public class ApkProvider extends FDroidProvider {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private QuerySelection queryRepoApps(long repoId, String packageNames) {
 | 
			
		||||
        return queryRepo(repoId).add(AppProvider.queryApps(packageNames, "app." + AppMetadataTable.Cols.PACKAGE_NAME));
 | 
			
		||||
        return queryRepo(repoId).add(AppProvider.queryPackageNames(packageNames, "app." + AppMetadataTable.Cols.PACKAGE_NAME));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected QuerySelection queryApks(String apkKeys) {
 | 
			
		||||
@ -456,15 +456,15 @@ public class ApkProvider extends FDroidProvider {
 | 
			
		||||
                break;
 | 
			
		||||
 | 
			
		||||
            case CODE_SINGLE:
 | 
			
		||||
                query = query.add(querySingle(uri));
 | 
			
		||||
                query = query.add(querySingleFromAnyRepo(uri));
 | 
			
		||||
                break;
 | 
			
		||||
 | 
			
		||||
            case CODE_APK_ROW_ID:
 | 
			
		||||
                query = query.add(querySingle(Long.parseLong(uri.getLastPathSegment())));
 | 
			
		||||
                break;
 | 
			
		||||
 | 
			
		||||
            case CODE_APP:
 | 
			
		||||
                query = query.add(queryApp(uri.getLastPathSegment()));
 | 
			
		||||
            case CODE_PACKAGE:
 | 
			
		||||
                query = query.add(queryPackage(uri.getLastPathSegment()));
 | 
			
		||||
                break;
 | 
			
		||||
 | 
			
		||||
            case CODE_APKS:
 | 
			
		||||
@ -505,7 +505,7 @@ public class ApkProvider extends FDroidProvider {
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        for (Map.Entry<String, String> appField : APP_FIELDS.entrySet()) {
 | 
			
		||||
        for (Map.Entry<String, String> appField : PACKAGE_FIELDS.entrySet()) {
 | 
			
		||||
            final String field = appField.getKey();
 | 
			
		||||
            if (values.containsKey(field)) {
 | 
			
		||||
                values.remove(field);
 | 
			
		||||
@ -535,8 +535,8 @@ public class ApkProvider extends FDroidProvider {
 | 
			
		||||
                query = query.add(queryRepo(Long.parseLong(uri.getLastPathSegment()), false));
 | 
			
		||||
                break;
 | 
			
		||||
 | 
			
		||||
            case CODE_APP:
 | 
			
		||||
                query = query.add(queryApp(uri.getLastPathSegment(), false));
 | 
			
		||||
            case CODE_PACKAGE:
 | 
			
		||||
                query = query.add(queryPackage(uri.getLastPathSegment(), false));
 | 
			
		||||
                break;
 | 
			
		||||
 | 
			
		||||
            case CODE_APKS:
 | 
			
		||||
@ -549,12 +549,6 @@ public class ApkProvider extends FDroidProvider {
 | 
			
		||||
                query = query.add(queryRepo(Long.parseLong(pathSegments.get(1)))).add(queryApks(pathSegments.get(2)));
 | 
			
		||||
                break;
 | 
			
		||||
 | 
			
		||||
            case CODE_LIST:
 | 
			
		||||
                throw new UnsupportedOperationException("Can't delete all apks.");
 | 
			
		||||
 | 
			
		||||
            case CODE_SINGLE:
 | 
			
		||||
                throw new UnsupportedOperationException("Can't delete individual apks.");
 | 
			
		||||
 | 
			
		||||
            default:
 | 
			
		||||
                Log.e(TAG, "Invalid URI for apk content provider: " + uri);
 | 
			
		||||
                throw new UnsupportedOperationException("Invalid URI for apk content provider: " + uri);
 | 
			
		||||
@ -579,7 +573,7 @@ public class ApkProvider extends FDroidProvider {
 | 
			
		||||
        removeFieldsFromOtherTables(values);
 | 
			
		||||
 | 
			
		||||
        QuerySelection query = new QuerySelection(where, whereArgs);
 | 
			
		||||
        query = query.add(querySingle(uri, false));
 | 
			
		||||
        query = query.add(querySingleFromAnyRepo(uri, false));
 | 
			
		||||
 | 
			
		||||
        int numRows = db().update(getTableName(), values, query.getSelection(), query.getArgs());
 | 
			
		||||
        if (!isApplyingBatch()) {
 | 
			
		||||
 | 
			
		||||
@ -127,7 +127,10 @@ public class AppProvider extends FDroidProvider {
 | 
			
		||||
        public static App findByPackageName(ContentResolver resolver, String packageName,
 | 
			
		||||
                                            String[] projection) {
 | 
			
		||||
            final Uri uri = getContentUri(packageName);
 | 
			
		||||
            Cursor cursor = resolver.query(uri, projection, null, null, null);
 | 
			
		||||
            return cursorToApp(resolver.query(uri, projection, null, null, null));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private static App cursorToApp(Cursor cursor) {
 | 
			
		||||
            App app = null;
 | 
			
		||||
            if (cursor != null) {
 | 
			
		||||
                if (cursor.getCount() > 0) {
 | 
			
		||||
@ -675,7 +678,7 @@ public class AppProvider extends FDroidProvider {
 | 
			
		||||
        return new AppQuerySelection(selection);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    static AppQuerySelection queryApps(String packageNames, String packageNameField) {
 | 
			
		||||
    static AppQuerySelection queryPackageNames(String packageNames, String packageNameField) {
 | 
			
		||||
        String[] args = packageNames.split(",");
 | 
			
		||||
        String selection = packageNameField + " IN (" + generateQuestionMarksForInClause(args.length) + ")";
 | 
			
		||||
        return new AppQuerySelection(selection, args);
 | 
			
		||||
@ -727,8 +730,9 @@ public class AppProvider extends FDroidProvider {
 | 
			
		||||
                break;
 | 
			
		||||
 | 
			
		||||
            case SEARCH_REPO:
 | 
			
		||||
                selection = selection.add(querySearch(uri.getPathSegments().get(2)));
 | 
			
		||||
                selection = selection.add(queryRepo(Long.parseLong(uri.getPathSegments().get(1))));
 | 
			
		||||
                selection = selection
 | 
			
		||||
                        .add(querySearch(uri.getPathSegments().get(2)))
 | 
			
		||||
                        .add(queryRepo(Long.parseLong(uri.getPathSegments().get(1))));
 | 
			
		||||
                break;
 | 
			
		||||
 | 
			
		||||
            case NO_APKS:
 | 
			
		||||
 | 
			
		||||
@ -149,8 +149,7 @@ public class RepoProvider extends FDroidProvider {
 | 
			
		||||
            return repo;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static void update(Context context, Repo repo,
 | 
			
		||||
                                  ContentValues values) {
 | 
			
		||||
        public static void update(Context context, Repo repo, ContentValues values) {
 | 
			
		||||
            ContentResolver resolver = context.getContentResolver();
 | 
			
		||||
 | 
			
		||||
            // Change the name to the new address. Next time we update the repo
 | 
			
		||||
@ -316,7 +315,7 @@ public class RepoProvider extends FDroidProvider {
 | 
			
		||||
                break;
 | 
			
		||||
 | 
			
		||||
            case CODE_ALL_EXCEPT_SWAP:
 | 
			
		||||
                selection = Cols.IS_SWAP + " = 0 OR " + Cols.IS_SWAP + " IS NULL ";
 | 
			
		||||
                selection = "COALESCE(" + Cols.IS_SWAP + ", 0) = 0 ";
 | 
			
		||||
                break;
 | 
			
		||||
 | 
			
		||||
            default:
 | 
			
		||||
 | 
			
		||||
@ -69,7 +69,7 @@ public class TempAppProvider extends AppProvider {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private AppQuerySelection queryApps(String packageNames) {
 | 
			
		||||
        return queryApps(packageNames, getTableName() + "." + AppMetadataTable.Cols.PACKAGE_NAME);
 | 
			
		||||
        return queryPackageNames(packageNames, getTableName() + "." + AppMetadataTable.Cols.PACKAGE_NAME);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static class Helper {
 | 
			
		||||
 | 
			
		||||
@ -97,7 +97,7 @@ public abstract class Installer {
 | 
			
		||||
            // no permission screen needed!
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
        Uri uri = ApkProvider.getContentUri(apk);
 | 
			
		||||
        Uri uri = ApkProvider.getApkFromAnyRepoUri(apk);
 | 
			
		||||
        Intent intent = new Intent(context, InstallConfirmActivity.class);
 | 
			
		||||
        intent.setData(uri);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -190,7 +190,7 @@ public class InstallConfirmActivity extends FragmentActivity implements OnCancel
 | 
			
		||||
 | 
			
		||||
        intent = getIntent();
 | 
			
		||||
        Uri uri = intent.getData();
 | 
			
		||||
        Apk apk = ApkProvider.Helper.find(this, uri, Schema.ApkTable.Cols.ALL);
 | 
			
		||||
        Apk apk = ApkProvider.Helper.findByUri(this, uri, Schema.ApkTable.Cols.ALL);
 | 
			
		||||
        app = AppProvider.Helper.findByPackageName(getContentResolver(), apk.packageName);
 | 
			
		||||
 | 
			
		||||
        appDiff = new AppDiff(getPackageManager(), apk);
 | 
			
		||||
 | 
			
		||||
@ -48,7 +48,7 @@ import org.fdroid.fdroid.data.ApkProvider;
 | 
			
		||||
import org.fdroid.fdroid.data.App;
 | 
			
		||||
import org.fdroid.fdroid.data.AppProvider;
 | 
			
		||||
import org.fdroid.fdroid.data.Repo;
 | 
			
		||||
import org.fdroid.fdroid.data.Schema;
 | 
			
		||||
import org.fdroid.fdroid.data.Schema.AppMetadataTable;
 | 
			
		||||
import org.fdroid.fdroid.localrepo.SwapService;
 | 
			
		||||
import org.fdroid.fdroid.net.Downloader;
 | 
			
		||||
import org.fdroid.fdroid.net.DownloaderService;
 | 
			
		||||
@ -104,7 +104,7 @@ public class SwapAppsView extends ListView implements
 | 
			
		||||
        */
 | 
			
		||||
 | 
			
		||||
        adapter = new AppListAdapter(getContext(), getContext().getContentResolver().query(
 | 
			
		||||
                AppProvider.getRepoUri(repo), Schema.AppMetadataTable.Cols.ALL, null, null, null));
 | 
			
		||||
                AppProvider.getRepoUri(repo), AppMetadataTable.Cols.ALL, null, null, null));
 | 
			
		||||
 | 
			
		||||
        setAdapter(adapter);
 | 
			
		||||
 | 
			
		||||
@ -194,7 +194,7 @@ public class SwapAppsView extends ListView implements
 | 
			
		||||
                ? AppProvider.getRepoUri(repo)
 | 
			
		||||
                : AppProvider.getSearchUri(repo, mCurrentFilterString);
 | 
			
		||||
 | 
			
		||||
        return new CursorLoader(getActivity(), uri, Schema.AppMetadataTable.Cols.ALL, null, null, Schema.AppMetadataTable.Cols.NAME);
 | 
			
		||||
        return new CursorLoader(getActivity(), uri, AppMetadataTable.Cols.ALL, null, null, AppMetadataTable.Cols.NAME);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
@ -304,7 +304,7 @@ public class SwapAppsView extends ListView implements
 | 
			
		||||
                    this.app = app;
 | 
			
		||||
 | 
			
		||||
                    Context context = getContext();
 | 
			
		||||
                    Apk apk = ApkProvider.Helper.find(context, app.packageName, app.suggestedVersionCode);
 | 
			
		||||
                    Apk apk = ApkProvider.Helper.findApkFromAnyRepo(context, app.packageName, app.suggestedVersionCode);
 | 
			
		||||
                    String urlString = apk.getUrl();
 | 
			
		||||
 | 
			
		||||
                    // TODO unregister receivers? or will they just die with this instance
 | 
			
		||||
 | 
			
		||||
@ -766,7 +766,7 @@ public class SwapWorkflowActivity extends AppCompatActivity {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void install(@NonNull final App app) {
 | 
			
		||||
        final Apk apk = ApkProvider.Helper.find(this, app.packageName, app.suggestedVersionCode);
 | 
			
		||||
        final Apk apk = ApkProvider.Helper.findApkFromAnyRepo(this, app.packageName, app.suggestedVersionCode);
 | 
			
		||||
        Uri downloadUri = Uri.parse(apk.getUrl());
 | 
			
		||||
        localBroadcastManager.registerReceiver(installReceiver,
 | 
			
		||||
                Installer.getInstallIntentFilter(downloadUri));
 | 
			
		||||
 | 
			
		||||
@ -69,8 +69,8 @@ public class ApkProviderTest extends FDroidProviderTest {
 | 
			
		||||
        Apk apk = new MockApk("org.fdroid.fdroid", 10);
 | 
			
		||||
 | 
			
		||||
        assertCantDelete(contentResolver, ApkProvider.getContentUri());
 | 
			
		||||
        assertCantDelete(contentResolver, ApkProvider.getContentUri("org.fdroid.fdroid", 10));
 | 
			
		||||
        assertCantDelete(contentResolver, ApkProvider.getContentUri(apk));
 | 
			
		||||
        assertCantDelete(contentResolver, ApkProvider.getApkFromAnyRepoUri("org.fdroid.fdroid", 10));
 | 
			
		||||
        assertCantDelete(contentResolver, ApkProvider.getApkFromAnyRepoUri(apk));
 | 
			
		||||
        assertCantDelete(contentResolver, Uri.withAppendedPath(ApkProvider.getContentUri(), "some-random-path"));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -411,7 +411,7 @@ public class ApkProviderTest extends FDroidProviderTest {
 | 
			
		||||
            Assert.insertApk(context, "com.other.thing." + i, i);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        Apk apk = ApkProvider.Helper.find(context, "com.example", 11);
 | 
			
		||||
        Apk apk = ApkProvider.Helper.findApkFromAnyRepo(context, "com.example", 11);
 | 
			
		||||
 | 
			
		||||
        assertNotNull(apk);
 | 
			
		||||
 | 
			
		||||
@ -428,7 +428,7 @@ public class ApkProviderTest extends FDroidProviderTest {
 | 
			
		||||
            Cols.HASH,
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
        Apk apkLessFields = ApkProvider.Helper.find(context, "com.example", 11, projection);
 | 
			
		||||
        Apk apkLessFields = ApkProvider.Helper.findApkFromAnyRepo(context, "com.example", 11, projection);
 | 
			
		||||
 | 
			
		||||
        assertNotNull(apkLessFields);
 | 
			
		||||
 | 
			
		||||
@ -440,7 +440,7 @@ public class ApkProviderTest extends FDroidProviderTest {
 | 
			
		||||
        assertNull(apkLessFields.versionName);
 | 
			
		||||
        assertEquals(0, apkLessFields.versionCode);
 | 
			
		||||
 | 
			
		||||
        Apk notFound = ApkProvider.Helper.find(context, "com.doesnt.exist", 1000);
 | 
			
		||||
        Apk notFound = ApkProvider.Helper.findApkFromAnyRepo(context, "com.doesnt.exist", 1000);
 | 
			
		||||
        assertNull(notFound);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -135,9 +135,9 @@ public class ProviderUriTests {
 | 
			
		||||
 | 
			
		||||
        assertValidUri(resolver, ApkProvider.getContentUri(), "content://org.fdroid.fdroid.data.ApkProvider", projection);
 | 
			
		||||
        assertValidUri(resolver, ApkProvider.getAppUri("org.fdroid.fdroid"), "content://org.fdroid.fdroid.data.ApkProvider/app/org.fdroid.fdroid", projection);
 | 
			
		||||
        assertValidUri(resolver, ApkProvider.getContentUri(new MockApk("org.fdroid.fdroid", 100)), "content://org.fdroid.fdroid.data.ApkProvider/apk/100/org.fdroid.fdroid", projection);
 | 
			
		||||
        assertValidUri(resolver, ApkProvider.getApkFromAnyRepoUri(new MockApk("org.fdroid.fdroid", 100)), "content://org.fdroid.fdroid.data.ApkProvider/apk/100/org.fdroid.fdroid", projection);
 | 
			
		||||
        assertValidUri(resolver, ApkProvider.getContentUri(apks), projection);
 | 
			
		||||
        assertValidUri(resolver, ApkProvider.getContentUri("org.fdroid.fdroid", 100), "content://org.fdroid.fdroid.data.ApkProvider/apk/100/org.fdroid.fdroid", projection);
 | 
			
		||||
        assertValidUri(resolver, ApkProvider.getApkFromAnyRepoUri("org.fdroid.fdroid", 100), "content://org.fdroid.fdroid.data.ApkProvider/apk/100/org.fdroid.fdroid", projection);
 | 
			
		||||
        assertValidUri(resolver, ApkProvider.getRepoUri(1000), "content://org.fdroid.fdroid.data.ApkProvider/repo/1000", projection);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user