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