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}.
|
* also known as {@code urlString}.
|
||||||
* @see org.fdroid.fdroid.installer.InstallManagerService
|
* @see org.fdroid.fdroid.installer.InstallManagerService
|
||||||
*/
|
*/
|
||||||
public String getUniqueKey() {
|
public String getCanonicalUrl() {
|
||||||
return apk.getCanonicalUrl();
|
return apk.getCanonicalUrl();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -264,7 +264,7 @@ public final class AppUpdateStatusManager {
|
|||||||
notifyChange(entry, isStatusUpdate);
|
notifyChange(entry, isStatusUpdate);
|
||||||
|
|
||||||
if (status == Status.Installed) {
|
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());
|
Utils.debugLog(LOGTAG, "Add APK " + apk.apkName + " with state " + status.name());
|
||||||
AppUpdateStatus entry = createAppEntry(apk, status, intent);
|
AppUpdateStatus entry = createAppEntry(apk, status, intent);
|
||||||
setEntryContentIntentIfEmpty(entry);
|
setEntryContentIntentIfEmpty(entry);
|
||||||
appMapping.put(entry.getUniqueKey(), entry);
|
appMapping.put(entry.getCanonicalUrl(), entry);
|
||||||
notifyAdd(entry);
|
notifyAdd(entry);
|
||||||
|
|
||||||
if (status == Status.Installed) {
|
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) {
|
private void notifyAdd(AppUpdateStatus entry) {
|
||||||
if (!isBatchUpdating) {
|
if (!isBatchUpdating) {
|
||||||
Intent broadcastIntent = new Intent(BROADCAST_APPSTATUS_ADDED);
|
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());
|
broadcastIntent.putExtra(EXTRA_STATUS, entry.copy());
|
||||||
localBroadcastManager.sendBroadcast(broadcastIntent);
|
localBroadcastManager.sendBroadcast(broadcastIntent);
|
||||||
}
|
}
|
||||||
@ -300,7 +300,7 @@ public final class AppUpdateStatusManager {
|
|||||||
private void notifyChange(AppUpdateStatus entry, boolean isStatusUpdate) {
|
private void notifyChange(AppUpdateStatus entry, boolean isStatusUpdate) {
|
||||||
if (!isBatchUpdating) {
|
if (!isBatchUpdating) {
|
||||||
Intent broadcastIntent = new Intent(BROADCAST_APPSTATUS_CHANGED);
|
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_STATUS, entry.copy());
|
||||||
broadcastIntent.putExtra(EXTRA_IS_STATUS_UPDATE, isStatusUpdate);
|
broadcastIntent.putExtra(EXTRA_IS_STATUS_UPDATE, isStatusUpdate);
|
||||||
localBroadcastManager.sendBroadcast(broadcastIntent);
|
localBroadcastManager.sendBroadcast(broadcastIntent);
|
||||||
@ -310,7 +310,7 @@ public final class AppUpdateStatusManager {
|
|||||||
private void notifyRemove(AppUpdateStatus entry) {
|
private void notifyRemove(AppUpdateStatus entry) {
|
||||||
if (!isBatchUpdating) {
|
if (!isBatchUpdating) {
|
||||||
Intent broadcastIntent = new Intent(BROADCAST_APPSTATUS_REMOVED);
|
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());
|
broadcastIntent.putExtra(EXTRA_STATUS, entry.copy());
|
||||||
localBroadcastManager.sendBroadcast(broadcastIntent);
|
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.
|
* @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) {
|
public void setDownloadError(String url, @Nullable String errorText) {
|
||||||
synchronized (appMapping) {
|
synchronized (appMapping) {
|
||||||
AppUpdateStatus entry = appMapping.get(url);
|
AppUpdateStatus entry = appMapping.get(url);
|
||||||
@ -444,7 +445,7 @@ public final class AppUpdateStatusManager {
|
|||||||
entry.intent = getAppErrorIntent(entry);
|
entry.intent = getAppErrorIntent(entry);
|
||||||
notifyChange(entry, false);
|
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) {
|
private void createNotification(AppUpdateStatusManager.AppUpdateStatus entry) {
|
||||||
if (shouldIgnoreEntry(entry)) {
|
if (shouldIgnoreEntry(entry)) {
|
||||||
notificationManager.cancel(entry.getUniqueKey(), NOTIFY_ID_UPDATES);
|
notificationManager.cancel(entry.getCanonicalUrl(), NOTIFY_ID_UPDATES);
|
||||||
notificationManager.cancel(entry.getUniqueKey(), NOTIFY_ID_INSTALLED);
|
notificationManager.cancel(entry.getCanonicalUrl(), NOTIFY_ID_INSTALLED);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -177,23 +177,23 @@ class NotificationHelper {
|
|||||||
if (entry.status == AppUpdateStatusManager.Status.Installed) {
|
if (entry.status == AppUpdateStatusManager.Status.Installed) {
|
||||||
if (useStackedNotifications()) {
|
if (useStackedNotifications()) {
|
||||||
notification = createInstalledNotification(entry);
|
notification = createInstalledNotification(entry);
|
||||||
notificationManager.cancel(entry.getUniqueKey(), NOTIFY_ID_UPDATES);
|
notificationManager.cancel(entry.getCanonicalUrl(), NOTIFY_ID_UPDATES);
|
||||||
notificationManager.notify(entry.getUniqueKey(), NOTIFY_ID_INSTALLED, notification);
|
notificationManager.notify(entry.getCanonicalUrl(), NOTIFY_ID_INSTALLED, notification);
|
||||||
} else if (installed.size() == 1) {
|
} else if (installed.size() == 1) {
|
||||||
notification = createInstalledNotification(entry);
|
notification = createInstalledNotification(entry);
|
||||||
notificationManager.cancel(entry.getUniqueKey(), NOTIFY_ID_UPDATES);
|
notificationManager.cancel(entry.getCanonicalUrl(), NOTIFY_ID_UPDATES);
|
||||||
notificationManager.cancel(entry.getUniqueKey(), NOTIFY_ID_INSTALLED);
|
notificationManager.cancel(entry.getCanonicalUrl(), NOTIFY_ID_INSTALLED);
|
||||||
notificationManager.notify(GROUP_INSTALLED, NOTIFY_ID_INSTALLED, notification);
|
notificationManager.notify(GROUP_INSTALLED, NOTIFY_ID_INSTALLED, notification);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (useStackedNotifications()) {
|
if (useStackedNotifications()) {
|
||||||
notification = createUpdateNotification(entry);
|
notification = createUpdateNotification(entry);
|
||||||
notificationManager.cancel(entry.getUniqueKey(), NOTIFY_ID_INSTALLED);
|
notificationManager.cancel(entry.getCanonicalUrl(), NOTIFY_ID_INSTALLED);
|
||||||
notificationManager.notify(entry.getUniqueKey(), NOTIFY_ID_UPDATES, notification);
|
notificationManager.notify(entry.getCanonicalUrl(), NOTIFY_ID_UPDATES, notification);
|
||||||
} else if (updates.size() == 1) {
|
} else if (updates.size() == 1) {
|
||||||
notification = createUpdateNotification(entry);
|
notification = createUpdateNotification(entry);
|
||||||
notificationManager.cancel(entry.getUniqueKey(), NOTIFY_ID_UPDATES);
|
notificationManager.cancel(entry.getCanonicalUrl(), NOTIFY_ID_UPDATES);
|
||||||
notificationManager.cancel(entry.getUniqueKey(), NOTIFY_ID_INSTALLED);
|
notificationManager.cancel(entry.getCanonicalUrl(), NOTIFY_ID_INSTALLED);
|
||||||
notificationManager.notify(GROUP_UPDATES, NOTIFY_ID_UPDATES, notification);
|
notificationManager.notify(GROUP_UPDATES, NOTIFY_ID_UPDATES, notification);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -346,7 +346,7 @@ class NotificationHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Intent intentDeleted = new Intent(BROADCAST_NOTIFICATIONS_UPDATE_CLEARED);
|
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);
|
intentDeleted.setClass(context, NotificationBroadcastReceiver.class);
|
||||||
PendingIntent piDeleted = PendingIntent.getBroadcast(context, 0, intentDeleted, PendingIntent.FLAG_UPDATE_CURRENT);
|
PendingIntent piDeleted = PendingIntent.getBroadcast(context, 0, intentDeleted, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||||
builder.setDeleteIntent(piDeleted);
|
builder.setDeleteIntent(piDeleted);
|
||||||
@ -435,7 +435,7 @@ class NotificationHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Intent intentDeleted = new Intent(BROADCAST_NOTIFICATIONS_INSTALLED_CLEARED);
|
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);
|
intentDeleted.setClass(context, NotificationBroadcastReceiver.class);
|
||||||
PendingIntent piDeleted = PendingIntent.getBroadcast(context, 0, intentDeleted, PendingIntent.FLAG_UPDATE_CURRENT);
|
PendingIntent piDeleted = PendingIntent.getBroadcast(context, 0, intentDeleted, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||||
builder.setDeleteIntent(piDeleted);
|
builder.setDeleteIntent(piDeleted);
|
||||||
@ -540,7 +540,7 @@ class NotificationHelper {
|
|||||||
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
|
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
|
||||||
// Need to check that the notification is still valid, and also that the image
|
// 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.
|
// 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
|
if (oldEntry != null
|
||||||
&& oldEntry.app != null
|
&& oldEntry.app != null
|
||||||
&& oldEntry.app.iconUrl != null
|
&& oldEntry.app.iconUrl != null
|
||||||
|
@ -237,7 +237,7 @@ public class InstalledAppProviderService extends JobIntentService {
|
|||||||
PackageInfo packageInfo = getPackageInfo(intent, packageName);
|
PackageInfo packageInfo = getPackageInfo(intent, packageName);
|
||||||
if (packageInfo != null) {
|
if (packageInfo != null) {
|
||||||
for (AppUpdateStatusManager.AppUpdateStatus status : ausm.getByPackageName(packageName)) {
|
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);
|
File apk = getPathToInstalledApk(packageInfo);
|
||||||
if (apk == null) {
|
if (apk == null) {
|
||||||
@ -258,7 +258,7 @@ public class InstalledAppProviderService extends JobIntentService {
|
|||||||
} else if (ACTION_DELETE.equals(action)) {
|
} else if (ACTION_DELETE.equals(action)) {
|
||||||
deleteAppFromDb(this, packageName);
|
deleteAppFromDb(this, packageName);
|
||||||
for (AppUpdateStatusManager.AppUpdateStatus status : ausm.getByPackageName(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);
|
packageChangeNotifier.onNext(packageName);
|
||||||
|
@ -171,9 +171,9 @@ public class AppDetailsActivity extends AppCompatActivity
|
|||||||
AppUpdateStatusManager ausm = AppUpdateStatusManager.getInstance(this);
|
AppUpdateStatusManager ausm = AppUpdateStatusManager.getInstance(this);
|
||||||
for (AppUpdateStatusManager.AppUpdateStatus status : ausm.getByPackageName(app.packageName)) {
|
for (AppUpdateStatusManager.AppUpdateStatus status : ausm.getByPackageName(app.packageName)) {
|
||||||
if (status.status == AppUpdateStatusManager.Status.Installed) {
|
if (status.status == AppUpdateStatusManager.Status.Installed) {
|
||||||
ausm.removeApk(status.getUniqueKey());
|
ausm.removeApk(status.getCanonicalUrl());
|
||||||
} else {
|
} else {
|
||||||
ausm.refreshApk(status.getUniqueKey());
|
ausm.refreshApk(status.getCanonicalUrl());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -449,7 +449,7 @@ public class AppDetailsActivity extends AppCompatActivity
|
|||||||
if (justReceived) {
|
if (justReceived) {
|
||||||
adapter.setIndeterminateProgress(R.string.installing);
|
adapter.setIndeterminateProgress(R.string.installing);
|
||||||
localBroadcastManager.registerReceiver(installReceiver,
|
localBroadcastManager.registerReceiver(installReceiver,
|
||||||
Installer.getInstallIntentFilter(Uri.parse(newStatus.getUniqueKey())));
|
Installer.getInstallIntentFilter(Uri.parse(newStatus.getCanonicalUrl())));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -459,7 +459,7 @@ public class AppDetailsActivity extends AppCompatActivity
|
|||||||
Toast.makeText(this, R.string.details_notinstalled, Toast.LENGTH_LONG).show();
|
Toast.makeText(this, R.string.details_notinstalled, Toast.LENGTH_LONG).show();
|
||||||
} else {
|
} else {
|
||||||
String msg = newStatus.errorText;
|
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, R.string.download_error, Toast.LENGTH_SHORT).show();
|
||||||
Toast.makeText(this, msg, Toast.LENGTH_LONG).show();
|
Toast.makeText(this, msg, Toast.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
@ -491,9 +491,9 @@ public class AppDetailsActivity extends AppCompatActivity
|
|||||||
AppUpdateStatusManager.BROADCAST_APPSTATUS_REMOVED);
|
AppUpdateStatusManager.BROADCAST_APPSTATUS_REMOVED);
|
||||||
if (currentStatus != null
|
if (currentStatus != null
|
||||||
&& isRemoving
|
&& isRemoving
|
||||||
&& !TextUtils.equals(status.getUniqueKey(), currentStatus.getUniqueKey())) {
|
&& !TextUtils.equals(status.getCanonicalUrl(), currentStatus.getCanonicalUrl())) {
|
||||||
Utils.debugLog(TAG, "Ignoring app status change because it belongs to "
|
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)) {
|
} else if (status != null && !TextUtils.equals(status.apk.packageName, app.packageName)) {
|
||||||
Utils.debugLog(TAG, "Ignoring app status change because it belongs to "
|
Utils.debugLog(TAG, "Ignoring app status change because it belongs to "
|
||||||
+ status.apk.packageName + " not " + app.packageName);
|
+ status.apk.packageName + " not " + app.packageName);
|
||||||
@ -650,7 +650,7 @@ public class AppDetailsActivity extends AppCompatActivity
|
|||||||
AppUpdateStatusManager ausm = AppUpdateStatusManager.getInstance(this);
|
AppUpdateStatusManager ausm = AppUpdateStatusManager.getInstance(this);
|
||||||
for (AppUpdateStatusManager.AppUpdateStatus status : ausm.getByPackageName(packageName)) {
|
for (AppUpdateStatusManager.AppUpdateStatus status : ausm.getByPackageName(packageName)) {
|
||||||
if (status.status == AppUpdateStatusManager.Status.Installed) {
|
if (status.status == AppUpdateStatusManager.Status.Installed) {
|
||||||
ausm.removeApk(status.getUniqueKey());
|
ausm.removeApk(status.getCanonicalUrl());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (app == null) {
|
if (app == null) {
|
||||||
@ -720,7 +720,7 @@ public class AppDetailsActivity extends AppCompatActivity
|
|||||||
@Override
|
@Override
|
||||||
public void installCancel() {
|
public void installCancel() {
|
||||||
if (currentStatus != null) {
|
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
|
// 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
|
// any sort of notification that the app was successfully installed. It should be
|
||||||
// apparent to the user because they just launched it.
|
// apparent to the user because they just launched it.
|
||||||
AppUpdateStatusManager.getInstance(activity).removeApk(currentStatus.getUniqueKey());
|
AppUpdateStatusManager.getInstance(activity).removeApk(currentStatus.getCanonicalUrl());
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -534,6 +534,6 @@ public abstract class AppListItemController extends RecyclerView.ViewHolder {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
InstallManagerService.cancel(activity, currentStatus.getUniqueKey());
|
InstallManagerService.cancel(activity, currentStatus.getCanonicalUrl());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ public class AppStatusListItemController extends AppListItemController {
|
|||||||
CharSequence message = null;
|
CharSequence message = null;
|
||||||
if (status != null) {
|
if (status != null) {
|
||||||
AppUpdateStatusManager manager = AppUpdateStatusManager.getInstance(activity);
|
AppUpdateStatusManager manager = AppUpdateStatusManager.getInstance(activity);
|
||||||
manager.removeApk(status.getUniqueKey());
|
manager.removeApk(status.getCanonicalUrl());
|
||||||
switch (status.status) {
|
switch (status.status) {
|
||||||
case Downloading:
|
case Downloading:
|
||||||
cancelDownload();
|
cancelDownload();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user