rename AppUpdateStatus.getUniqueKey to getCanonicalUrl
This highlights the relationship between the various things that are using the canonical URL as the unique ID.
This commit is contained in:
parent
4ea775be00
commit
e346d2351b
@ -132,7 +132,7 @@ public final class AppUpdateStatusManager {
|
||||
* also known as {@code urlString}.
|
||||
* @see org.fdroid.fdroid.installer.InstallManagerService
|
||||
*/
|
||||
public String getUniqueKey() {
|
||||
public String getCanonicalUrl() {
|
||||
return apk.getCanonicalUrl();
|
||||
}
|
||||
|
||||
@ -264,7 +264,7 @@ public final class AppUpdateStatusManager {
|
||||
notifyChange(entry, isStatusUpdate);
|
||||
|
||||
if (status == Status.Installed) {
|
||||
InstallManagerService.removePendingInstall(context, entry.getUniqueKey());
|
||||
InstallManagerService.removePendingInstall(context, entry.getCanonicalUrl());
|
||||
}
|
||||
}
|
||||
|
||||
@ -272,11 +272,11 @@ public final class AppUpdateStatusManager {
|
||||
Utils.debugLog(LOGTAG, "Add APK " + apk.apkName + " with state " + status.name());
|
||||
AppUpdateStatus entry = createAppEntry(apk, status, intent);
|
||||
setEntryContentIntentIfEmpty(entry);
|
||||
appMapping.put(entry.getUniqueKey(), entry);
|
||||
appMapping.put(entry.getCanonicalUrl(), entry);
|
||||
notifyAdd(entry);
|
||||
|
||||
if (status == Status.Installed) {
|
||||
InstallManagerService.removePendingInstall(context, entry.getUniqueKey());
|
||||
InstallManagerService.removePendingInstall(context, entry.getCanonicalUrl());
|
||||
}
|
||||
}
|
||||
|
||||
@ -291,7 +291,7 @@ public final class AppUpdateStatusManager {
|
||||
private void notifyAdd(AppUpdateStatus entry) {
|
||||
if (!isBatchUpdating) {
|
||||
Intent broadcastIntent = new Intent(BROADCAST_APPSTATUS_ADDED);
|
||||
broadcastIntent.putExtra(EXTRA_APK_URL, entry.getUniqueKey());
|
||||
broadcastIntent.putExtra(EXTRA_APK_URL, entry.getCanonicalUrl());
|
||||
broadcastIntent.putExtra(EXTRA_STATUS, entry.copy());
|
||||
localBroadcastManager.sendBroadcast(broadcastIntent);
|
||||
}
|
||||
@ -300,7 +300,7 @@ public final class AppUpdateStatusManager {
|
||||
private void notifyChange(AppUpdateStatus entry, boolean isStatusUpdate) {
|
||||
if (!isBatchUpdating) {
|
||||
Intent broadcastIntent = new Intent(BROADCAST_APPSTATUS_CHANGED);
|
||||
broadcastIntent.putExtra(EXTRA_APK_URL, entry.getUniqueKey());
|
||||
broadcastIntent.putExtra(EXTRA_APK_URL, entry.getCanonicalUrl());
|
||||
broadcastIntent.putExtra(EXTRA_STATUS, entry.copy());
|
||||
broadcastIntent.putExtra(EXTRA_IS_STATUS_UPDATE, isStatusUpdate);
|
||||
localBroadcastManager.sendBroadcast(broadcastIntent);
|
||||
@ -310,7 +310,7 @@ public final class AppUpdateStatusManager {
|
||||
private void notifyRemove(AppUpdateStatus entry) {
|
||||
if (!isBatchUpdating) {
|
||||
Intent broadcastIntent = new Intent(BROADCAST_APPSTATUS_REMOVED);
|
||||
broadcastIntent.putExtra(EXTRA_APK_URL, entry.getUniqueKey());
|
||||
broadcastIntent.putExtra(EXTRA_APK_URL, entry.getCanonicalUrl());
|
||||
broadcastIntent.putExtra(EXTRA_STATUS, entry.copy());
|
||||
localBroadcastManager.sendBroadcast(broadcastIntent);
|
||||
}
|
||||
@ -420,6 +420,7 @@ public final class AppUpdateStatusManager {
|
||||
/**
|
||||
* @param errorText If null, then it is likely because the user cancelled the download.
|
||||
*/
|
||||
// TODO should url actually be canonicalUrl?
|
||||
public void setDownloadError(String url, @Nullable String errorText) {
|
||||
synchronized (appMapping) {
|
||||
AppUpdateStatus entry = appMapping.get(url);
|
||||
@ -444,7 +445,7 @@ public final class AppUpdateStatusManager {
|
||||
entry.intent = getAppErrorIntent(entry);
|
||||
notifyChange(entry, false);
|
||||
|
||||
InstallManagerService.removePendingInstall(context, entry.getUniqueKey());
|
||||
InstallManagerService.removePendingInstall(context, entry.getCanonicalUrl());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -164,8 +164,8 @@ class NotificationHelper {
|
||||
|
||||
private void createNotification(AppUpdateStatusManager.AppUpdateStatus entry) {
|
||||
if (shouldIgnoreEntry(entry)) {
|
||||
notificationManager.cancel(entry.getUniqueKey(), NOTIFY_ID_UPDATES);
|
||||
notificationManager.cancel(entry.getUniqueKey(), NOTIFY_ID_INSTALLED);
|
||||
notificationManager.cancel(entry.getCanonicalUrl(), NOTIFY_ID_UPDATES);
|
||||
notificationManager.cancel(entry.getCanonicalUrl(), NOTIFY_ID_INSTALLED);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -177,23 +177,23 @@ class NotificationHelper {
|
||||
if (entry.status == AppUpdateStatusManager.Status.Installed) {
|
||||
if (useStackedNotifications()) {
|
||||
notification = createInstalledNotification(entry);
|
||||
notificationManager.cancel(entry.getUniqueKey(), NOTIFY_ID_UPDATES);
|
||||
notificationManager.notify(entry.getUniqueKey(), NOTIFY_ID_INSTALLED, notification);
|
||||
notificationManager.cancel(entry.getCanonicalUrl(), NOTIFY_ID_UPDATES);
|
||||
notificationManager.notify(entry.getCanonicalUrl(), NOTIFY_ID_INSTALLED, notification);
|
||||
} else if (installed.size() == 1) {
|
||||
notification = createInstalledNotification(entry);
|
||||
notificationManager.cancel(entry.getUniqueKey(), NOTIFY_ID_UPDATES);
|
||||
notificationManager.cancel(entry.getUniqueKey(), NOTIFY_ID_INSTALLED);
|
||||
notificationManager.cancel(entry.getCanonicalUrl(), NOTIFY_ID_UPDATES);
|
||||
notificationManager.cancel(entry.getCanonicalUrl(), NOTIFY_ID_INSTALLED);
|
||||
notificationManager.notify(GROUP_INSTALLED, NOTIFY_ID_INSTALLED, notification);
|
||||
}
|
||||
} else {
|
||||
if (useStackedNotifications()) {
|
||||
notification = createUpdateNotification(entry);
|
||||
notificationManager.cancel(entry.getUniqueKey(), NOTIFY_ID_INSTALLED);
|
||||
notificationManager.notify(entry.getUniqueKey(), NOTIFY_ID_UPDATES, notification);
|
||||
notificationManager.cancel(entry.getCanonicalUrl(), NOTIFY_ID_INSTALLED);
|
||||
notificationManager.notify(entry.getCanonicalUrl(), NOTIFY_ID_UPDATES, notification);
|
||||
} else if (updates.size() == 1) {
|
||||
notification = createUpdateNotification(entry);
|
||||
notificationManager.cancel(entry.getUniqueKey(), NOTIFY_ID_UPDATES);
|
||||
notificationManager.cancel(entry.getUniqueKey(), NOTIFY_ID_INSTALLED);
|
||||
notificationManager.cancel(entry.getCanonicalUrl(), NOTIFY_ID_UPDATES);
|
||||
notificationManager.cancel(entry.getCanonicalUrl(), NOTIFY_ID_INSTALLED);
|
||||
notificationManager.notify(GROUP_UPDATES, NOTIFY_ID_UPDATES, notification);
|
||||
}
|
||||
}
|
||||
@ -346,7 +346,7 @@ class NotificationHelper {
|
||||
}
|
||||
|
||||
Intent intentDeleted = new Intent(BROADCAST_NOTIFICATIONS_UPDATE_CLEARED);
|
||||
intentDeleted.putExtra(EXTRA_NOTIFICATION_KEY, entry.getUniqueKey());
|
||||
intentDeleted.putExtra(EXTRA_NOTIFICATION_KEY, entry.getCanonicalUrl());
|
||||
intentDeleted.setClass(context, NotificationBroadcastReceiver.class);
|
||||
PendingIntent piDeleted = PendingIntent.getBroadcast(context, 0, intentDeleted, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
builder.setDeleteIntent(piDeleted);
|
||||
@ -435,7 +435,7 @@ class NotificationHelper {
|
||||
}
|
||||
|
||||
Intent intentDeleted = new Intent(BROADCAST_NOTIFICATIONS_INSTALLED_CLEARED);
|
||||
intentDeleted.putExtra(EXTRA_NOTIFICATION_KEY, entry.getUniqueKey());
|
||||
intentDeleted.putExtra(EXTRA_NOTIFICATION_KEY, entry.getCanonicalUrl());
|
||||
intentDeleted.setClass(context, NotificationBroadcastReceiver.class);
|
||||
PendingIntent piDeleted = PendingIntent.getBroadcast(context, 0, intentDeleted, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
builder.setDeleteIntent(piDeleted);
|
||||
@ -540,7 +540,7 @@ class NotificationHelper {
|
||||
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
|
||||
// Need to check that the notification is still valid, and also that the image
|
||||
// is indeed cached now, so we won't get stuck in an endless loop.
|
||||
AppUpdateStatusManager.AppUpdateStatus oldEntry = appUpdateStatusManager.get(entry.getUniqueKey());
|
||||
AppUpdateStatusManager.AppUpdateStatus oldEntry = appUpdateStatusManager.get(entry.getCanonicalUrl());
|
||||
if (oldEntry != null
|
||||
&& oldEntry.app != null
|
||||
&& oldEntry.app.iconUrl != null
|
||||
|
@ -237,7 +237,7 @@ public class InstalledAppProviderService extends JobIntentService {
|
||||
PackageInfo packageInfo = getPackageInfo(intent, packageName);
|
||||
if (packageInfo != null) {
|
||||
for (AppUpdateStatusManager.AppUpdateStatus status : ausm.getByPackageName(packageName)) {
|
||||
ausm.updateApk(status.getUniqueKey(), AppUpdateStatusManager.Status.Installed, null);
|
||||
ausm.updateApk(status.getCanonicalUrl(), AppUpdateStatusManager.Status.Installed, null);
|
||||
}
|
||||
File apk = getPathToInstalledApk(packageInfo);
|
||||
if (apk == null) {
|
||||
@ -258,7 +258,7 @@ public class InstalledAppProviderService extends JobIntentService {
|
||||
} else if (ACTION_DELETE.equals(action)) {
|
||||
deleteAppFromDb(this, packageName);
|
||||
for (AppUpdateStatusManager.AppUpdateStatus status : ausm.getByPackageName(packageName)) {
|
||||
ausm.updateApk(status.getUniqueKey(), AppUpdateStatusManager.Status.InstallError, null);
|
||||
ausm.updateApk(status.getCanonicalUrl(), AppUpdateStatusManager.Status.InstallError, null);
|
||||
}
|
||||
}
|
||||
packageChangeNotifier.onNext(packageName);
|
||||
|
@ -171,9 +171,9 @@ public class AppDetailsActivity extends AppCompatActivity
|
||||
AppUpdateStatusManager ausm = AppUpdateStatusManager.getInstance(this);
|
||||
for (AppUpdateStatusManager.AppUpdateStatus status : ausm.getByPackageName(app.packageName)) {
|
||||
if (status.status == AppUpdateStatusManager.Status.Installed) {
|
||||
ausm.removeApk(status.getUniqueKey());
|
||||
ausm.removeApk(status.getCanonicalUrl());
|
||||
} else {
|
||||
ausm.refreshApk(status.getUniqueKey());
|
||||
ausm.refreshApk(status.getCanonicalUrl());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -449,7 +449,7 @@ public class AppDetailsActivity extends AppCompatActivity
|
||||
if (justReceived) {
|
||||
adapter.setIndeterminateProgress(R.string.installing);
|
||||
localBroadcastManager.registerReceiver(installReceiver,
|
||||
Installer.getInstallIntentFilter(Uri.parse(newStatus.getUniqueKey())));
|
||||
Installer.getInstallIntentFilter(Uri.parse(newStatus.getCanonicalUrl())));
|
||||
}
|
||||
break;
|
||||
|
||||
@ -459,7 +459,7 @@ public class AppDetailsActivity extends AppCompatActivity
|
||||
Toast.makeText(this, R.string.details_notinstalled, Toast.LENGTH_LONG).show();
|
||||
} else {
|
||||
String msg = newStatus.errorText;
|
||||
if (!newStatus.getUniqueKey().equals(msg)) msg += " " + newStatus.getUniqueKey();
|
||||
if (!newStatus.getCanonicalUrl().equals(msg)) msg += " " + newStatus.getCanonicalUrl();
|
||||
Toast.makeText(this, R.string.download_error, Toast.LENGTH_SHORT).show();
|
||||
Toast.makeText(this, msg, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
@ -491,9 +491,9 @@ public class AppDetailsActivity extends AppCompatActivity
|
||||
AppUpdateStatusManager.BROADCAST_APPSTATUS_REMOVED);
|
||||
if (currentStatus != null
|
||||
&& isRemoving
|
||||
&& !TextUtils.equals(status.getUniqueKey(), currentStatus.getUniqueKey())) {
|
||||
&& !TextUtils.equals(status.getCanonicalUrl(), currentStatus.getCanonicalUrl())) {
|
||||
Utils.debugLog(TAG, "Ignoring app status change because it belongs to "
|
||||
+ status.getUniqueKey() + " not " + currentStatus.getUniqueKey());
|
||||
+ status.getCanonicalUrl() + " not " + currentStatus.getCanonicalUrl());
|
||||
} else if (status != null && !TextUtils.equals(status.apk.packageName, app.packageName)) {
|
||||
Utils.debugLog(TAG, "Ignoring app status change because it belongs to "
|
||||
+ status.apk.packageName + " not " + app.packageName);
|
||||
@ -650,7 +650,7 @@ public class AppDetailsActivity extends AppCompatActivity
|
||||
AppUpdateStatusManager ausm = AppUpdateStatusManager.getInstance(this);
|
||||
for (AppUpdateStatusManager.AppUpdateStatus status : ausm.getByPackageName(packageName)) {
|
||||
if (status.status == AppUpdateStatusManager.Status.Installed) {
|
||||
ausm.removeApk(status.getUniqueKey());
|
||||
ausm.removeApk(status.getCanonicalUrl());
|
||||
}
|
||||
}
|
||||
if (app == null) {
|
||||
@ -720,7 +720,7 @@ public class AppDetailsActivity extends AppCompatActivity
|
||||
@Override
|
||||
public void installCancel() {
|
||||
if (currentStatus != null) {
|
||||
InstallManagerService.cancel(this, currentStatus.getUniqueKey());
|
||||
InstallManagerService.cancel(this, currentStatus.getCanonicalUrl());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -477,7 +477,7 @@ public abstract class AppListItemController extends RecyclerView.ViewHolder {
|
||||
// Once it is explicitly launched by the user, then we can pretty much forget about
|
||||
// any sort of notification that the app was successfully installed. It should be
|
||||
// apparent to the user because they just launched it.
|
||||
AppUpdateStatusManager.getInstance(activity).removeApk(currentStatus.getUniqueKey());
|
||||
AppUpdateStatusManager.getInstance(activity).removeApk(currentStatus.getCanonicalUrl());
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -534,6 +534,6 @@ public abstract class AppListItemController extends RecyclerView.ViewHolder {
|
||||
return;
|
||||
}
|
||||
|
||||
InstallManagerService.cancel(activity, currentStatus.getUniqueKey());
|
||||
InstallManagerService.cancel(activity, currentStatus.getCanonicalUrl());
|
||||
}
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ public class AppStatusListItemController extends AppListItemController {
|
||||
CharSequence message = null;
|
||||
if (status != null) {
|
||||
AppUpdateStatusManager manager = AppUpdateStatusManager.getInstance(activity);
|
||||
manager.removeApk(status.getUniqueKey());
|
||||
manager.removeApk(status.getCanonicalUrl());
|
||||
switch (status.status) {
|
||||
case Downloading:
|
||||
cancelDownload();
|
||||
|
Loading…
x
Reference in New Issue
Block a user