Merge branch 'rename-id-to-package-name' into 'master'
Renaming id -> packageName in local variables/method args/comments/etc. Building on the previous MR. This finishes renaming "id" in the Java code to "package name" where appropriate. It still leaves the database symbols as "id" because they are not worth the effort to rename at this point in time. See merge request !184
This commit is contained in:
commit
892b47c060
@ -36,7 +36,7 @@
|
||||
tools:text="Application manager" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/appid"
|
||||
android:id="@+id/package_name"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="12sp"
|
||||
|
@ -171,7 +171,7 @@ public class AppDetails extends AppCompatActivity implements ProgressListener, A
|
||||
|
||||
ApkListAdapter(Context context, App app) {
|
||||
super(context, 0);
|
||||
final List<Apk> apks = ApkProvider.Helper.findByApp(context, app.packageName);
|
||||
final List<Apk> apks = ApkProvider.Helper.findByPackageName(context, app.packageName);
|
||||
for (final Apk apk : apks) {
|
||||
if (apk.compatible || Preferences.get().showIncompatibleVersions()) {
|
||||
add(apk);
|
||||
@ -353,14 +353,14 @@ public class AppDetails extends AppCompatActivity implements ProgressListener, A
|
||||
private boolean inProcessOfChangingConfiguration;
|
||||
|
||||
/**
|
||||
* Attempt to extract the appId from the intent which launched this activity.
|
||||
* @return May return null, if we couldn't find the appId. This should
|
||||
* Attempt to extract the packageName from the intent which launched this activity.
|
||||
* @return May return null, if we couldn't find the packageName. This should
|
||||
* never happen as AppDetails is only to be called by the FDroid activity
|
||||
* and not externally.
|
||||
*/
|
||||
private String getAppIdFromIntent(Intent intent) {
|
||||
private String getPackageNameFromIntent(Intent intent) {
|
||||
if (!intent.hasExtra(EXTRA_APPID)) {
|
||||
Log.e(TAG, "No application ID found in the intent!");
|
||||
Log.e(TAG, "No package name found in the intent!");
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -399,7 +399,7 @@ public class AppDetails extends AppCompatActivity implements ProgressListener, A
|
||||
app = previousData.app;
|
||||
setApp(app);
|
||||
} else {
|
||||
if (!reset(getAppIdFromIntent(intent))) {
|
||||
if (!reset(getPackageNameFromIntent(intent))) {
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
@ -541,9 +541,9 @@ public class AppDetails extends AppCompatActivity implements ProgressListener, A
|
||||
supportInvalidateOptionsMenu();
|
||||
}
|
||||
|
||||
private void setIgnoreUpdates(String appId, boolean ignoreAll, int ignoreVersionCode) {
|
||||
private void setIgnoreUpdates(String packageName, boolean ignoreAll, int ignoreVersionCode) {
|
||||
|
||||
Uri uri = AppProvider.getContentUri(appId);
|
||||
Uri uri = AppProvider.getContentUri(packageName);
|
||||
|
||||
ContentValues values = new ContentValues(2);
|
||||
values.put(AppProvider.DataColumns.IGNORE_ALLUPDATES, ignoreAll ? 1 : 0);
|
||||
@ -574,13 +574,13 @@ public class AppDetails extends AppCompatActivity implements ProgressListener, A
|
||||
// Reset the display and list contents. Used when entering the activity, and
|
||||
// also when something has been installed/uninstalled.
|
||||
// Return true if the app was found, false otherwise.
|
||||
private boolean reset(String appId) {
|
||||
private boolean reset(String packageName) {
|
||||
|
||||
Utils.debugLog(TAG, "Getting application details for " + appId);
|
||||
Utils.debugLog(TAG, "Getting application details for " + packageName);
|
||||
App newApp = null;
|
||||
|
||||
if (!TextUtils.isEmpty(appId)) {
|
||||
newApp = AppProvider.Helper.findById(getContentResolver(), appId);
|
||||
if (!TextUtils.isEmpty(packageName)) {
|
||||
newApp = AppProvider.Helper.findByPackageName(getContentResolver(), packageName);
|
||||
}
|
||||
|
||||
setApp(newApp);
|
||||
@ -952,8 +952,8 @@ public class AppDetails extends AppCompatActivity implements ProgressListener, A
|
||||
}
|
||||
};
|
||||
|
||||
private void launchApk(String id) {
|
||||
Intent intent = mPm.getLaunchIntentForPackage(id);
|
||||
private void launchApk(String packageName) {
|
||||
Intent intent = mPm.getLaunchIntentForPackage(packageName);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
@ -1208,11 +1208,11 @@ public class AppDetails extends AppCompatActivity implements ProgressListener, A
|
||||
});
|
||||
|
||||
// App ID
|
||||
final TextView appIdView = (TextView) view.findViewById(R.id.appid);
|
||||
final TextView packageNameView = (TextView) view.findViewById(R.id.package_name);
|
||||
if (prefs.expertMode())
|
||||
appIdView.setText(app.packageName);
|
||||
packageNameView.setText(app.packageName);
|
||||
else
|
||||
appIdView.setVisibility(View.GONE);
|
||||
packageNameView.setVisibility(View.GONE);
|
||||
|
||||
// Summary
|
||||
final TextView summaryView = (TextView) view.findViewById(R.id.summary);
|
||||
|
@ -158,7 +158,7 @@ public class FDroid extends AppCompatActivity implements SearchView.OnQueryTextL
|
||||
|
||||
final String scheme = data.getScheme();
|
||||
final String path = data.getPath();
|
||||
String appId = null;
|
||||
String packageName = null;
|
||||
String query = null;
|
||||
if (data.isHierarchical()) {
|
||||
final String host = data.getHost();
|
||||
@ -171,19 +171,19 @@ public class FDroid extends AppCompatActivity implements SearchView.OnQueryTextL
|
||||
// http://f-droid.org/repository/browse?fdfilter=search+query
|
||||
query = UriCompat.getQueryParameter(data, "fdfilter");
|
||||
|
||||
// http://f-droid.org/repository/browse?fdid=app.id
|
||||
appId = UriCompat.getQueryParameter(data, "fdid");
|
||||
// http://f-droid.org/repository/browse?fdid=packageName
|
||||
packageName = UriCompat.getQueryParameter(data, "fdid");
|
||||
} else if (path.startsWith("/app")) {
|
||||
// http://f-droid.org/app/app.id
|
||||
appId = data.getLastPathSegment();
|
||||
if ("app".equals(appId)) {
|
||||
appId = null;
|
||||
// http://f-droid.org/app/packageName
|
||||
packageName = data.getLastPathSegment();
|
||||
if ("app".equals(packageName)) {
|
||||
packageName = null;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "details":
|
||||
// market://details?id=app.id
|
||||
appId = UriCompat.getQueryParameter(data, "id");
|
||||
packageName = UriCompat.getQueryParameter(data, "id");
|
||||
break;
|
||||
case "search":
|
||||
// market://search?q=query
|
||||
@ -192,7 +192,7 @@ public class FDroid extends AppCompatActivity implements SearchView.OnQueryTextL
|
||||
case "play.google.com":
|
||||
if (path.startsWith("/store/apps/details")) {
|
||||
// http://play.google.com/store/apps/details?id=app.id
|
||||
appId = UriCompat.getQueryParameter(data, "id");
|
||||
packageName = UriCompat.getQueryParameter(data, "id");
|
||||
} else if (path.startsWith("/store/search")) {
|
||||
// http://play.google.com/store/search?q=foo
|
||||
query = UriCompat.getQueryParameter(data, "q");
|
||||
@ -203,13 +203,13 @@ public class FDroid extends AppCompatActivity implements SearchView.OnQueryTextL
|
||||
case "www.amazon.com":
|
||||
// amzn://apps/android?p=app.id
|
||||
// http://amazon.com/gp/mas/dl/android?s=app.id
|
||||
appId = UriCompat.getQueryParameter(data, "p");
|
||||
packageName = UriCompat.getQueryParameter(data, "p");
|
||||
query = UriCompat.getQueryParameter(data, "s");
|
||||
break;
|
||||
}
|
||||
} else if ("fdroid.app".equals(scheme)) {
|
||||
// fdroid.app:app.id
|
||||
appId = data.getSchemeSpecificPart();
|
||||
packageName = data.getSchemeSpecificPart();
|
||||
} else if ("fdroid.search".equals(scheme)) {
|
||||
// fdroid.search:query
|
||||
query = data.getSchemeSpecificPart();
|
||||
@ -218,17 +218,17 @@ public class FDroid extends AppCompatActivity implements SearchView.OnQueryTextL
|
||||
if (!TextUtils.isEmpty(query)) {
|
||||
// an old format for querying via packageName
|
||||
if (query.startsWith("pname:"))
|
||||
appId = query.split(":")[1];
|
||||
packageName = query.split(":")[1];
|
||||
|
||||
// sometimes, search URLs include pub: or other things before the query string
|
||||
if (query.contains(":"))
|
||||
query = query.split(":")[1];
|
||||
}
|
||||
|
||||
if (!TextUtils.isEmpty(appId)) {
|
||||
Utils.debugLog(TAG, "FDroid launched via app link for '" + appId + "'");
|
||||
if (!TextUtils.isEmpty(packageName)) {
|
||||
Utils.debugLog(TAG, "FDroid launched via app link for '" + packageName + "'");
|
||||
Intent intentToInvoke = new Intent(this, AppDetails.class);
|
||||
intentToInvoke.putExtra(AppDetails.EXTRA_APPID, appId);
|
||||
intentToInvoke.putExtra(AppDetails.EXTRA_APPID, packageName);
|
||||
startActivity(intentToInvoke);
|
||||
} else if (!TextUtils.isEmpty(query)) {
|
||||
Utils.debugLog(TAG, "FDroid launched via search link for '" + query + "'");
|
||||
|
@ -84,8 +84,8 @@ public class ApkProvider extends FDroidProvider {
|
||||
resolver.delete(uri, null, null);
|
||||
}
|
||||
|
||||
public static Apk find(Context context, String id, int versionCode) {
|
||||
return find(context, id, versionCode, DataColumns.ALL);
|
||||
public static Apk find(Context context, String packageName, int versionCode) {
|
||||
return find(context, packageName, versionCode, DataColumns.ALL);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -106,9 +106,9 @@ public class ApkProvider extends FDroidProvider {
|
||||
return find(context, repo, apps, DataColumns.ALL);
|
||||
}
|
||||
|
||||
public static Apk find(Context context, String id, int versionCode, String[] projection) {
|
||||
public static Apk find(Context context, String packageName, int versionCode, String[] projection) {
|
||||
ContentResolver resolver = context.getContentResolver();
|
||||
final Uri uri = getContentUri(id, versionCode);
|
||||
final Uri uri = getContentUri(packageName, versionCode);
|
||||
Cursor cursor = resolver.query(uri, projection, null, null, null);
|
||||
Apk apk = null;
|
||||
if (cursor != null) {
|
||||
@ -121,14 +121,14 @@ public class ApkProvider extends FDroidProvider {
|
||||
return apk;
|
||||
}
|
||||
|
||||
public static List<Apk> findByApp(Context context, String appId) {
|
||||
return findByApp(context, appId, ApkProvider.DataColumns.ALL);
|
||||
public static List<Apk> findByPackageName(Context context, String packageName) {
|
||||
return findByPackageName(context, packageName, ApkProvider.DataColumns.ALL);
|
||||
}
|
||||
|
||||
public static List<Apk> findByApp(Context context,
|
||||
String appId, String[] projection) {
|
||||
public static List<Apk> findByPackageName(Context context,
|
||||
String packageName, String[] projection) {
|
||||
ContentResolver resolver = context.getContentResolver();
|
||||
final Uri uri = getAppUri(appId);
|
||||
final Uri uri = getAppUri(packageName);
|
||||
final String sort = ApkProvider.DataColumns.VERSION_CODE + " DESC";
|
||||
Cursor cursor = resolver.query(uri, projection, null, null, sort);
|
||||
return cursorToList(cursor);
|
||||
@ -262,11 +262,11 @@ public class ApkProvider extends FDroidProvider {
|
||||
return Uri.parse("content://" + getAuthority());
|
||||
}
|
||||
|
||||
public static Uri getAppUri(String appId) {
|
||||
public static Uri getAppUri(String packageName) {
|
||||
return getContentUri()
|
||||
.buildUpon()
|
||||
.appendPath(PATH_APP)
|
||||
.appendPath(appId)
|
||||
.appendPath(packageName)
|
||||
.build();
|
||||
}
|
||||
|
||||
@ -282,12 +282,12 @@ public class ApkProvider extends FDroidProvider {
|
||||
return getContentUri(apk.packageName, apk.vercode);
|
||||
}
|
||||
|
||||
public static Uri getContentUri(String id, int versionCode) {
|
||||
public static Uri getContentUri(String packageName, int versionCode) {
|
||||
return getContentUri()
|
||||
.buildUpon()
|
||||
.appendPath(PATH_APK)
|
||||
.appendPath(Integer.toString(versionCode))
|
||||
.appendPath(id)
|
||||
.appendPath(packageName)
|
||||
.build();
|
||||
}
|
||||
|
||||
@ -394,9 +394,9 @@ public class ApkProvider extends FDroidProvider {
|
||||
|
||||
}
|
||||
|
||||
private QuerySelection queryApp(String appId) {
|
||||
private QuerySelection queryApp(String packageName) {
|
||||
final String selection = DataColumns.PACKAGE_NAME + " = ? ";
|
||||
final String[] args = {appId};
|
||||
final String[] args = {packageName};
|
||||
return new QuerySelection(selection, args);
|
||||
}
|
||||
|
||||
@ -417,8 +417,8 @@ public class ApkProvider extends FDroidProvider {
|
||||
return new QuerySelection(selection, args);
|
||||
}
|
||||
|
||||
private QuerySelection queryRepoApps(long repoId, String appIds) {
|
||||
return queryRepo(repoId).add(AppProvider.queryApps(appIds, DataColumns.PACKAGE_NAME));
|
||||
private QuerySelection queryRepoApps(long repoId, String packageNames) {
|
||||
return queryRepo(repoId).add(AppProvider.queryApps(packageNames, DataColumns.PACKAGE_NAME));
|
||||
}
|
||||
|
||||
protected QuerySelection queryApks(String apkKeys) {
|
||||
@ -432,9 +432,9 @@ public class ApkProvider extends FDroidProvider {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < apkDetails.length; i++) {
|
||||
String[] parts = apkDetails[i].split(":");
|
||||
String id = parts[0];
|
||||
String packageName = parts[0];
|
||||
String verCode = parts[1];
|
||||
args[i * 2] = id;
|
||||
args[i * 2] = packageName;
|
||||
args[i * 2 + 1] = verCode;
|
||||
if (i != 0) {
|
||||
sb.append(" OR ");
|
||||
|
@ -121,13 +121,13 @@ public class AppProvider extends FDroidProvider {
|
||||
return categories;
|
||||
}
|
||||
|
||||
public static App findById(ContentResolver resolver, String appId) {
|
||||
return findById(resolver, appId, DataColumns.ALL);
|
||||
public static App findByPackageName(ContentResolver resolver, String packageName) {
|
||||
return findByPackageName(resolver, packageName, DataColumns.ALL);
|
||||
}
|
||||
|
||||
public static App findById(ContentResolver resolver, String appId,
|
||||
public static App findByPackageName(ContentResolver resolver, String packageName,
|
||||
String[] projection) {
|
||||
final Uri uri = getContentUri(appId);
|
||||
final Uri uri = getContentUri(packageName);
|
||||
Cursor cursor = resolver.query(uri, projection, null, null, null);
|
||||
App app = null;
|
||||
if (cursor != null) {
|
||||
@ -327,7 +327,7 @@ public class AppProvider extends FDroidProvider {
|
||||
join(
|
||||
DBHelper.TABLE_INSTALLED_APP,
|
||||
"installed",
|
||||
"installed." + InstalledAppProvider.DataColumns.APP_ID + " = " + getTableName() + ".id");
|
||||
"installed." + InstalledAppProvider.DataColumns.PACKAGE_NAME + " = " + getTableName() + ".id");
|
||||
requiresInstalledTable = true;
|
||||
}
|
||||
}
|
||||
@ -337,7 +337,7 @@ public class AppProvider extends FDroidProvider {
|
||||
leftJoin(
|
||||
DBHelper.TABLE_INSTALLED_APP,
|
||||
"installed",
|
||||
"installed." + InstalledAppProvider.DataColumns.APP_ID + " = " + getTableName() + ".id");
|
||||
"installed." + InstalledAppProvider.DataColumns.PACKAGE_NAME + " = " + getTableName() + ".id");
|
||||
requiresInstalledTable = true;
|
||||
}
|
||||
}
|
||||
@ -535,8 +535,8 @@ public class AppProvider extends FDroidProvider {
|
||||
return getContentUri(app.packageName);
|
||||
}
|
||||
|
||||
public static Uri getContentUri(String appId) {
|
||||
return Uri.withAppendedPath(getContentUri(), appId);
|
||||
public static Uri getContentUri(String packageName) {
|
||||
return Uri.withAppendedPath(getContentUri(), packageName);
|
||||
}
|
||||
|
||||
public static Uri getSearchUri(String query) {
|
||||
@ -656,9 +656,9 @@ public class AppProvider extends FDroidProvider {
|
||||
return new AppQuerySelection(selection.toString(), selectionKeywords);
|
||||
}
|
||||
|
||||
protected AppQuerySelection querySingle(String id) {
|
||||
protected AppQuerySelection querySingle(String packageName) {
|
||||
final String selection = getTableName() + ".id = ?";
|
||||
final String[] args = {id};
|
||||
final String[] args = {packageName};
|
||||
return new AppQuerySelection(selection, args);
|
||||
}
|
||||
|
||||
@ -712,14 +712,14 @@ public class AppProvider extends FDroidProvider {
|
||||
return new AppQuerySelection(selection);
|
||||
}
|
||||
|
||||
static AppQuerySelection queryApps(String appIds, String idField) {
|
||||
String[] args = appIds.split(",");
|
||||
static AppQuerySelection queryApps(String packageNames, String idField) {
|
||||
String[] args = packageNames.split(",");
|
||||
String selection = idField + " IN (" + generateQuestionMarksForInClause(args.length) + ")";
|
||||
return new AppQuerySelection(selection, args);
|
||||
}
|
||||
|
||||
private AppQuerySelection queryApps(String appIds) {
|
||||
return queryApps(appIds, getTableName() + ".id");
|
||||
private AppQuerySelection queryApps(String packageNames) {
|
||||
return queryApps(packageNames, getTableName() + ".id");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -96,7 +96,7 @@ public class DBHelper extends SQLiteOpenHelper {
|
||||
public static final String TABLE_INSTALLED_APP = "fdroid_installedApp";
|
||||
private static final String CREATE_TABLE_INSTALLED_APP = "CREATE TABLE " + TABLE_INSTALLED_APP
|
||||
+ " ( "
|
||||
+ InstalledAppProvider.DataColumns.APP_ID + " TEXT NOT NULL PRIMARY KEY, "
|
||||
+ InstalledAppProvider.DataColumns.PACKAGE_NAME + " TEXT NOT NULL PRIMARY KEY, "
|
||||
+ InstalledAppProvider.DataColumns.VERSION_CODE + " INT NOT NULL, "
|
||||
+ InstalledAppProvider.DataColumns.VERSION_NAME + " TEXT NOT NULL, "
|
||||
+ InstalledAppProvider.DataColumns.APPLICATION_LABEL + " TEXT NOT NULL, "
|
||||
|
@ -134,7 +134,7 @@ public class InstalledAppCacheUpdater {
|
||||
Uri uri = InstalledAppProvider.getContentUri();
|
||||
for (PackageInfo info : appsToInsert) {
|
||||
ContentProviderOperation op = ContentProviderOperation.newInsert(uri)
|
||||
.withValue(InstalledAppProvider.DataColumns.APP_ID, info.packageName)
|
||||
.withValue(InstalledAppProvider.DataColumns.PACKAGE_NAME, info.packageName)
|
||||
.withValue(InstalledAppProvider.DataColumns.VERSION_CODE, info.versionCode)
|
||||
.withValue(InstalledAppProvider.DataColumns.VERSION_NAME, info.versionName)
|
||||
.withValue(InstalledAppProvider.DataColumns.APPLICATION_LABEL,
|
||||
@ -148,12 +148,12 @@ public class InstalledAppCacheUpdater {
|
||||
return ops;
|
||||
}
|
||||
|
||||
private List<ContentProviderOperation> deleteFromCache(List<String> appIds) {
|
||||
List<ContentProviderOperation> ops = new ArrayList<>(appIds.size());
|
||||
if (appIds.size() > 0) {
|
||||
Utils.debugLog(TAG, "Preparing to remove " + appIds.size() + " apps from the installed app cache.");
|
||||
for (final String appId : appIds) {
|
||||
Uri uri = InstalledAppProvider.getAppUri(appId);
|
||||
private List<ContentProviderOperation> deleteFromCache(List<String> packageNames) {
|
||||
List<ContentProviderOperation> ops = new ArrayList<>(packageNames.size());
|
||||
if (packageNames.size() > 0) {
|
||||
Utils.debugLog(TAG, "Preparing to remove " + packageNames.size() + " apps from the installed app cache.");
|
||||
for (final String packageName : packageNames) {
|
||||
Uri uri = InstalledAppProvider.getAppUri(packageName);
|
||||
ops.add(ContentProviderOperation.newDelete(uri).build());
|
||||
}
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ public class InstalledAppProvider extends FDroidProvider {
|
||||
cursor.moveToFirst();
|
||||
while (!cursor.isAfterLast()) {
|
||||
cachedInfo.put(
|
||||
cursor.getString(cursor.getColumnIndex(InstalledAppProvider.DataColumns.APP_ID)),
|
||||
cursor.getString(cursor.getColumnIndex(InstalledAppProvider.DataColumns.PACKAGE_NAME)),
|
||||
cursor.getInt(cursor.getColumnIndex(InstalledAppProvider.DataColumns.VERSION_CODE))
|
||||
);
|
||||
cursor.moveToNext();
|
||||
@ -59,14 +59,14 @@ public class InstalledAppProvider extends FDroidProvider {
|
||||
public interface DataColumns {
|
||||
|
||||
String _ID = "rowid as _id"; // Required for CursorLoaders
|
||||
String APP_ID = "appId";
|
||||
String PACKAGE_NAME = "appId";
|
||||
String VERSION_CODE = "versionCode";
|
||||
String VERSION_NAME = "versionName";
|
||||
String APPLICATION_LABEL = "applicationLabel";
|
||||
String SIGNATURE = "sig";
|
||||
|
||||
String[] ALL = {
|
||||
_ID, APP_ID, VERSION_CODE, VERSION_NAME, APPLICATION_LABEL,
|
||||
_ID, PACKAGE_NAME, VERSION_CODE, VERSION_NAME, APPLICATION_LABEL,
|
||||
SIGNATURE,
|
||||
};
|
||||
|
||||
@ -89,8 +89,8 @@ public class InstalledAppProvider extends FDroidProvider {
|
||||
return Uri.parse("content://" + getAuthority());
|
||||
}
|
||||
|
||||
public static Uri getAppUri(String appId) {
|
||||
return Uri.withAppendedPath(getContentUri(), appId);
|
||||
public static Uri getAppUri(String packageName) {
|
||||
return Uri.withAppendedPath(getContentUri(), packageName);
|
||||
}
|
||||
|
||||
public static Uri getSearchUri(String keywords) {
|
||||
@ -146,8 +146,8 @@ public class InstalledAppProvider extends FDroidProvider {
|
||||
return matcher;
|
||||
}
|
||||
|
||||
private QuerySelection queryApp(String appId) {
|
||||
return new QuerySelection("appId = ?", new String[]{appId});
|
||||
private QuerySelection queryApp(String packageName) {
|
||||
return new QuerySelection("appId = ?", new String[]{packageName});
|
||||
}
|
||||
|
||||
private QuerySelection querySearch(String query) {
|
||||
@ -214,7 +214,7 @@ public class InstalledAppProvider extends FDroidProvider {
|
||||
if (!isApplyingBatch()) {
|
||||
getContext().getContentResolver().notifyChange(uri, null);
|
||||
}
|
||||
return getAppUri(values.getAsString(DataColumns.APP_ID));
|
||||
return getAppUri(values.getAsString(DataColumns.PACKAGE_NAME));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -217,7 +217,7 @@ public class RepoPersister {
|
||||
*/
|
||||
private boolean isAppInDatabase(App app) {
|
||||
String[] fields = {AppProvider.DataColumns.PACKAGE_NAME};
|
||||
App found = AppProvider.Helper.findById(context.getContentResolver(), app.packageName, fields);
|
||||
App found = AppProvider.Helper.findByPackageName(context.getContentResolver(), app.packageName, fields);
|
||||
return found != null;
|
||||
}
|
||||
|
||||
|
@ -23,11 +23,11 @@ import org.fdroid.fdroid.net.AsyncDownloaderFromAndroid;
|
||||
public class DownloadManagerReceiver extends BroadcastReceiver {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
// work out the app Id to send to the AppDetails Screen
|
||||
// work out the package name to send to the AppDetails Screen
|
||||
long downloadId = AsyncDownloaderFromAndroid.getDownloadId(intent);
|
||||
String appId = AsyncDownloaderFromAndroid.getDownloadId(context, downloadId);
|
||||
String packageName = AsyncDownloaderFromAndroid.getDownloadId(context, downloadId);
|
||||
|
||||
if (appId == null) {
|
||||
if (packageName == null) {
|
||||
// bogus broadcast (e.g. download cancelled, but system sent a DOWNLOAD_COMPLETE)
|
||||
return;
|
||||
}
|
||||
@ -36,10 +36,10 @@ public class DownloadManagerReceiver extends BroadcastReceiver {
|
||||
int status = AsyncDownloaderFromAndroid.validDownload(context, downloadId);
|
||||
if (status == 0) {
|
||||
// successful download
|
||||
showNotification(context, appId, intent, downloadId, R.string.tap_to_install);
|
||||
showNotification(context, packageName, intent, downloadId, R.string.tap_to_install);
|
||||
} else {
|
||||
// download failed!
|
||||
showNotification(context, appId, intent, downloadId, R.string.download_error);
|
||||
showNotification(context, packageName, intent, downloadId, R.string.download_error);
|
||||
|
||||
// clear the download to allow user to download again
|
||||
DownloadManager dm = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE);
|
||||
@ -51,19 +51,19 @@ public class DownloadManagerReceiver extends BroadcastReceiver {
|
||||
appDetails.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
appDetails.setAction(intent.getAction());
|
||||
appDetails.putExtras(intent.getExtras());
|
||||
appDetails.putExtra(AppDetails.EXTRA_APPID, appId);
|
||||
appDetails.putExtra(AppDetails.EXTRA_APPID, packageName);
|
||||
context.startActivity(appDetails);
|
||||
}
|
||||
}
|
||||
|
||||
private void showNotification(Context context, String appId, Intent intent, long downloadId,
|
||||
private void showNotification(Context context, String packageName, Intent intent, long downloadId,
|
||||
@StringRes int messageResId) {
|
||||
// show a notification the user can click to install the app
|
||||
Intent appDetails = new Intent(context, AppDetails.class);
|
||||
appDetails.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
appDetails.setAction(intent.getAction());
|
||||
appDetails.putExtra(DownloadManager.EXTRA_DOWNLOAD_ID, downloadId);
|
||||
appDetails.putExtra(AppDetails.EXTRA_APPID, appId);
|
||||
appDetails.putExtra(AppDetails.EXTRA_APPID, packageName);
|
||||
|
||||
// set separate pending intents per download id
|
||||
PendingIntent pi = PendingIntent.getActivity(
|
||||
|
@ -41,22 +41,22 @@ public class PackageAddedReceiver extends PackageReceiver {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handle(Context context, String appId) {
|
||||
PackageInfo info = getPackageInfo(context, appId);
|
||||
protected void handle(Context context, String packageName) {
|
||||
PackageInfo info = getPackageInfo(context, packageName);
|
||||
if (info == null) {
|
||||
Utils.debugLog(TAG, "Could not get package info on '" + appId + "' - skipping.");
|
||||
Utils.debugLog(TAG, "Could not get package info on '" + packageName + "' - skipping.");
|
||||
return;
|
||||
}
|
||||
|
||||
Utils.debugLog(TAG, "Inserting installed app info for '" + appId + "' (v" + info.versionCode + ")");
|
||||
Utils.debugLog(TAG, "Inserting installed app info for '" + packageName + "' (v" + info.versionCode + ")");
|
||||
|
||||
Uri uri = InstalledAppProvider.getContentUri();
|
||||
ContentValues values = new ContentValues(4);
|
||||
values.put(InstalledAppProvider.DataColumns.APP_ID, appId);
|
||||
values.put(InstalledAppProvider.DataColumns.PACKAGE_NAME, packageName);
|
||||
values.put(InstalledAppProvider.DataColumns.VERSION_CODE, info.versionCode);
|
||||
values.put(InstalledAppProvider.DataColumns.VERSION_NAME, info.versionName);
|
||||
values.put(InstalledAppProvider.DataColumns.APPLICATION_LABEL,
|
||||
InstalledAppProvider.getApplicationLabel(context, appId));
|
||||
InstalledAppProvider.getApplicationLabel(context, packageName));
|
||||
values.put(InstalledAppProvider.DataColumns.SIGNATURE,
|
||||
InstalledAppProvider.getPackageSig(info));
|
||||
context.getContentResolver().insert(uri, values);
|
||||
|
@ -35,12 +35,12 @@ abstract class PackageReceiver extends BroadcastReceiver {
|
||||
|
||||
protected abstract boolean toDiscard(Intent intent);
|
||||
|
||||
protected abstract void handle(Context context, String appId);
|
||||
protected abstract void handle(Context context, String packageName);
|
||||
|
||||
protected PackageInfo getPackageInfo(Context context, String appId) {
|
||||
protected PackageInfo getPackageInfo(Context context, String packageName) {
|
||||
PackageInfo info = null;
|
||||
try {
|
||||
info = context.getPackageManager().getPackageInfo(appId, PackageManager.GET_SIGNATURES);
|
||||
info = context.getPackageManager().getPackageInfo(packageName, PackageManager.GET_SIGNATURES);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
// ignore
|
||||
}
|
||||
@ -53,10 +53,10 @@ abstract class PackageReceiver extends BroadcastReceiver {
|
||||
if (toDiscard(intent)) {
|
||||
return;
|
||||
}
|
||||
String appId = intent.getData().getSchemeSpecificPart();
|
||||
handle(context, appId);
|
||||
context.getContentResolver().notifyChange(AppProvider.getContentUri(appId), null);
|
||||
context.getContentResolver().notifyChange(ApkProvider.getAppUri(appId), null);
|
||||
String packageName = intent.getData().getSchemeSpecificPart();
|
||||
handle(context, packageName);
|
||||
context.getContentResolver().notifyChange(AppProvider.getContentUri(packageName), null);
|
||||
context.getContentResolver().notifyChange(ApkProvider.getAppUri(packageName), null);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -39,11 +39,11 @@ public class PackageRemovedReceiver extends PackageReceiver {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handle(Context context, String appId) {
|
||||
protected void handle(Context context, String packageName) {
|
||||
|
||||
Utils.debugLog(TAG, "Removing installed app info for '" + appId + "'");
|
||||
Utils.debugLog(TAG, "Removing installed app info for '" + packageName + "'");
|
||||
|
||||
Uri uri = InstalledAppProvider.getAppUri(appId);
|
||||
Uri uri = InstalledAppProvider.getAppUri(packageName);
|
||||
context.getContentResolver().delete(uri, null, null);
|
||||
}
|
||||
|
||||
|
@ -43,22 +43,22 @@ public class PackageUpgradedReceiver extends PackageReceiver {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handle(Context context, String appId) {
|
||||
PackageInfo info = getPackageInfo(context, appId);
|
||||
protected void handle(Context context, String packageName) {
|
||||
PackageInfo info = getPackageInfo(context, packageName);
|
||||
if (info == null) {
|
||||
Utils.debugLog(TAG, "Could not get package info on '" + appId + "' - skipping.");
|
||||
Utils.debugLog(TAG, "Could not get package info on '" + packageName + "' - skipping.");
|
||||
return;
|
||||
}
|
||||
|
||||
Utils.debugLog(TAG, "Updating installed app info for '" + appId + "' to v" + info.versionCode + " (" + info.versionName + ")");
|
||||
Utils.debugLog(TAG, "Updating installed app info for '" + packageName + "' to v" + info.versionCode + " (" + info.versionName + ")");
|
||||
|
||||
Uri uri = InstalledAppProvider.getContentUri();
|
||||
ContentValues values = new ContentValues(4);
|
||||
values.put(InstalledAppProvider.DataColumns.APP_ID, appId);
|
||||
values.put(InstalledAppProvider.DataColumns.PACKAGE_NAME, packageName);
|
||||
values.put(InstalledAppProvider.DataColumns.VERSION_CODE, info.versionCode);
|
||||
values.put(InstalledAppProvider.DataColumns.VERSION_NAME, info.versionName);
|
||||
values.put(InstalledAppProvider.DataColumns.APPLICATION_LABEL,
|
||||
InstalledAppProvider.getApplicationLabel(context, appId));
|
||||
InstalledAppProvider.getApplicationLabel(context, packageName));
|
||||
values.put(InstalledAppProvider.DataColumns.SIGNATURE,
|
||||
InstalledAppProvider.getPackageSig(info));
|
||||
context.getContentResolver().insert(uri, values);
|
||||
|
@ -140,7 +140,7 @@ public class SelectAppsView extends ListView implements
|
||||
|
||||
private void toggleAppSelected(int position) {
|
||||
Cursor c = (Cursor) adapter.getItem(position);
|
||||
String packageName = c.getString(c.getColumnIndex(InstalledAppProvider.DataColumns.APP_ID));
|
||||
String packageName = c.getString(c.getColumnIndex(InstalledAppProvider.DataColumns.PACKAGE_NAME));
|
||||
if (getState().hasSelectedPackage(packageName)) {
|
||||
getState().deselectPackage(packageName);
|
||||
adapter.updateCheckedIndicatorView(position, false);
|
||||
@ -174,7 +174,7 @@ public class SelectAppsView extends ListView implements
|
||||
|
||||
for (int i = 0; i < getCount(); i++) {
|
||||
Cursor c = (Cursor) getItemAtPosition(i);
|
||||
String packageName = c.getString(c.getColumnIndex(InstalledAppProvider.DataColumns.APP_ID));
|
||||
String packageName = c.getString(c.getColumnIndex(InstalledAppProvider.DataColumns.PACKAGE_NAME));
|
||||
getState().ensureFDroidSelected();
|
||||
for (String selected : getState().getAppsToSwap()) {
|
||||
if (TextUtils.equals(packageName, selected)) {
|
||||
@ -258,7 +258,7 @@ public class SelectAppsView extends ListView implements
|
||||
TextView labelView = (TextView) view.findViewById(R.id.application_label);
|
||||
ImageView iconView = (ImageView) view.findViewById(android.R.id.icon);
|
||||
|
||||
String packageName = cursor.getString(cursor.getColumnIndex(InstalledAppProvider.DataColumns.APP_ID));
|
||||
String packageName = cursor.getString(cursor.getColumnIndex(InstalledAppProvider.DataColumns.PACKAGE_NAME));
|
||||
String appLabel = cursor.getString(cursor.getColumnIndex(InstalledAppProvider.DataColumns.APPLICATION_LABEL));
|
||||
|
||||
Drawable icon;
|
||||
|
@ -333,7 +333,7 @@ public class SwapAppsView extends ListView implements
|
||||
public void onChange(boolean selfChange) {
|
||||
Activity activity = getActivity();
|
||||
if (activity != null) {
|
||||
app = AppProvider.Helper.findById(getActivity().getContentResolver(), app.packageName);
|
||||
app = AppProvider.Helper.findByPackageName(getActivity().getContentResolver(), app.packageName);
|
||||
apkToInstall = null; // Force lazy loading to fetch correct apk next time.
|
||||
resetView();
|
||||
}
|
||||
|
@ -83,19 +83,19 @@ public class ApkProviderHelperTest extends BaseApkProviderTest {
|
||||
|
||||
assertTotalApkCount(7 + 9 + 3 + 1);
|
||||
|
||||
List<Apk> fdroidApks = ApkProvider.Helper.findByApp(getMockContext(), "org.fdroid.fdroid");
|
||||
List<Apk> fdroidApks = ApkProvider.Helper.findByPackageName(getMockContext(), "org.fdroid.fdroid");
|
||||
assertResultCount(7, fdroidApks);
|
||||
assertBelongsToApp(fdroidApks, "org.fdroid.fdroid");
|
||||
|
||||
List<Apk> exampleApks = ApkProvider.Helper.findByApp(getMockContext(), "org.example");
|
||||
List<Apk> exampleApks = ApkProvider.Helper.findByPackageName(getMockContext(), "org.example");
|
||||
assertResultCount(9, exampleApks);
|
||||
assertBelongsToApp(exampleApks, "org.example");
|
||||
|
||||
List<Apk> exampleApks2 = ApkProvider.Helper.findByApp(getMockContext(), "com.example");
|
||||
List<Apk> exampleApks2 = ApkProvider.Helper.findByPackageName(getMockContext(), "com.example");
|
||||
assertResultCount(3, exampleApks2);
|
||||
assertBelongsToApp(exampleApks2, "com.example");
|
||||
|
||||
List<Apk> thingoApks = ApkProvider.Helper.findByApp(getMockContext(), "com.apk.thingo");
|
||||
List<Apk> thingoApks = ApkProvider.Helper.findByPackageName(getMockContext(), "com.apk.thingo");
|
||||
assertResultCount(1, thingoApks);
|
||||
assertBelongsToApp(thingoApks, "com.apk.thingo");
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ public class AppProviderTest extends FDroidProviderTest<AppProvider> {
|
||||
}
|
||||
|
||||
public void testCantFindApp() {
|
||||
assertNull(AppProvider.Helper.findById(getMockContentResolver(), "com.example.doesnt-exist"));
|
||||
assertNull(AppProvider.Helper.findByPackageName(getMockContentResolver(), "com.example.doesnt-exist"));
|
||||
}
|
||||
|
||||
public void testUris() {
|
||||
@ -149,14 +149,14 @@ public class AppProviderTest extends FDroidProviderTest<AppProvider> {
|
||||
ContentResolver r = getMockContentResolver();
|
||||
|
||||
// Can't "update", although can "install"...
|
||||
App notInstalled = AppProvider.Helper.findById(r, "not installed");
|
||||
App notInstalled = AppProvider.Helper.findByPackageName(r, "not installed");
|
||||
assertFalse(notInstalled.canAndWantToUpdate());
|
||||
|
||||
App installedOnlyOneVersionAvailable = AppProvider.Helper.findById(r, "installed, only one version available");
|
||||
App installedAlreadyLatestNoIgnore = AppProvider.Helper.findById(r, "installed, already latest, no ignore");
|
||||
App installedAlreadyLatestIgnoreAll = AppProvider.Helper.findById(r, "installed, already latest, ignore all");
|
||||
App installedAlreadyLatestIgnoreLatest = AppProvider.Helper.findById(r, "installed, already latest, ignore latest");
|
||||
App installedAlreadyLatestIgnoreOld = AppProvider.Helper.findById(r, "installed, already latest, ignore old");
|
||||
App installedOnlyOneVersionAvailable = AppProvider.Helper.findByPackageName(r, "installed, only one version available");
|
||||
App installedAlreadyLatestNoIgnore = AppProvider.Helper.findByPackageName(r, "installed, already latest, no ignore");
|
||||
App installedAlreadyLatestIgnoreAll = AppProvider.Helper.findByPackageName(r, "installed, already latest, ignore all");
|
||||
App installedAlreadyLatestIgnoreLatest = AppProvider.Helper.findByPackageName(r, "installed, already latest, ignore latest");
|
||||
App installedAlreadyLatestIgnoreOld = AppProvider.Helper.findByPackageName(r, "installed, already latest, ignore old");
|
||||
|
||||
assertFalse(installedOnlyOneVersionAvailable.canAndWantToUpdate());
|
||||
assertFalse(installedAlreadyLatestNoIgnore.canAndWantToUpdate());
|
||||
@ -164,10 +164,10 @@ public class AppProviderTest extends FDroidProviderTest<AppProvider> {
|
||||
assertFalse(installedAlreadyLatestIgnoreLatest.canAndWantToUpdate());
|
||||
assertFalse(installedAlreadyLatestIgnoreOld.canAndWantToUpdate());
|
||||
|
||||
App installedOldNoIgnore = AppProvider.Helper.findById(r, "installed, old version, no ignore");
|
||||
App installedOldIgnoreAll = AppProvider.Helper.findById(r, "installed, old version, ignore all");
|
||||
App installedOldIgnoreLatest = AppProvider.Helper.findById(r, "installed, old version, ignore latest");
|
||||
App installedOldIgnoreNewerNotLatest = AppProvider.Helper.findById(r, "installed, old version, ignore newer, but not latest");
|
||||
App installedOldNoIgnore = AppProvider.Helper.findByPackageName(r, "installed, old version, no ignore");
|
||||
App installedOldIgnoreAll = AppProvider.Helper.findByPackageName(r, "installed, old version, ignore all");
|
||||
App installedOldIgnoreLatest = AppProvider.Helper.findByPackageName(r, "installed, old version, ignore latest");
|
||||
App installedOldIgnoreNewerNotLatest = AppProvider.Helper.findByPackageName(r, "installed, old version, ignore newer, but not latest");
|
||||
|
||||
assertTrue(installedOldNoIgnore.canAndWantToUpdate());
|
||||
assertFalse(installedOldIgnoreAll.canAndWantToUpdate());
|
||||
|
@ -156,7 +156,7 @@ public abstract class FDroidProviderTest<T extends FDroidProvider> extends Provi
|
||||
Uri uri = InstalledAppProvider.getAppUri(appId);
|
||||
|
||||
String[] projection = {
|
||||
InstalledAppProvider.DataColumns.APP_ID,
|
||||
InstalledAppProvider.DataColumns.PACKAGE_NAME,
|
||||
InstalledAppProvider.DataColumns.VERSION_CODE,
|
||||
InstalledAppProvider.DataColumns.VERSION_NAME,
|
||||
InstalledAppProvider.DataColumns.APPLICATION_LABEL,
|
||||
@ -169,7 +169,7 @@ public abstract class FDroidProviderTest<T extends FDroidProvider> extends Provi
|
||||
|
||||
cursor.moveToFirst();
|
||||
|
||||
assertEquals(appId, cursor.getString(cursor.getColumnIndex(InstalledAppProvider.DataColumns.APP_ID)));
|
||||
assertEquals(appId, cursor.getString(cursor.getColumnIndex(InstalledAppProvider.DataColumns.PACKAGE_NAME)));
|
||||
assertEquals(versionCode, cursor.getInt(cursor.getColumnIndex(InstalledAppProvider.DataColumns.VERSION_CODE)));
|
||||
assertEquals(versionName, cursor.getString(cursor.getColumnIndex(InstalledAppProvider.DataColumns.VERSION_NAME)));
|
||||
cursor.close();
|
||||
|
@ -28,7 +28,7 @@ public class InstalledAppCacheTest extends FDroidProviderTest<InstalledAppProvid
|
||||
@Override
|
||||
protected String[] getMinimalProjection() {
|
||||
return new String[] {
|
||||
InstalledAppProvider.DataColumns.APP_ID,
|
||||
InstalledAppProvider.DataColumns.PACKAGE_NAME,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -140,7 +140,7 @@ public class InstalledAppProviderTest extends FDroidProviderTest<InstalledAppPro
|
||||
@Override
|
||||
protected String[] getMinimalProjection() {
|
||||
return new String[] {
|
||||
InstalledAppProvider.DataColumns.APP_ID,
|
||||
InstalledAppProvider.DataColumns.PACKAGE_NAME,
|
||||
InstalledAppProvider.DataColumns.VERSION_CODE,
|
||||
InstalledAppProvider.DataColumns.VERSION_NAME,
|
||||
};
|
||||
@ -153,7 +153,7 @@ public class InstalledAppProviderTest extends FDroidProviderTest<InstalledAppPro
|
||||
private ContentValues createContentValues(String appId, int versionCode, String versionNumber) {
|
||||
ContentValues values = new ContentValues(3);
|
||||
if (appId != null) {
|
||||
values.put(InstalledAppProvider.DataColumns.APP_ID, appId);
|
||||
values.put(InstalledAppProvider.DataColumns.PACKAGE_NAME, appId);
|
||||
}
|
||||
values.put(InstalledAppProvider.DataColumns.APPLICATION_LABEL, "Mock app: " + appId);
|
||||
values.put(InstalledAppProvider.DataColumns.VERSION_CODE, versionCode);
|
||||
|
@ -174,7 +174,7 @@ public class MultiRepoUpdaterTest extends InstrumentationTestCase {
|
||||
}
|
||||
|
||||
private void assertApp(String packageName, int[] versionCodes) {
|
||||
List<Apk> apks = ApkProvider.Helper.findByApp(context, packageName, ApkProvider.DataColumns.ALL);
|
||||
List<Apk> apks = ApkProvider.Helper.findByPackageName(context, packageName, ApkProvider.DataColumns.ALL);
|
||||
assertApksExist(apks, packageName, versionCodes);
|
||||
}
|
||||
|
||||
@ -299,7 +299,7 @@ public class MultiRepoUpdaterTest extends InstrumentationTestCase {
|
||||
};
|
||||
|
||||
for (String id : packages) {
|
||||
assertEquals("No apks for " + id, 0, ApkProvider.Helper.findByApp(context, id).size());
|
||||
assertEquals("No apks for " + id, 0, ApkProvider.Helper.findByPackageName(context, id).size());
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user