PendingInstall event for announcing start of process
This adds a new PendingInstall event which broadcasts that an install process has started, but the state of it is not yet known, like whether it needs to be downloaded still, or is ready to install. It marks the very first step of the whole InstallManagerService process. Installer events should only be directly related to the install process as managed by the Installer set of classes. The newer AppStatusUpdate stuff now tracks the whole lifecycle of the process. This mostly reverts f0d6acd974548e24662a64271ae57922f74c3225 since there is now the overarching concept of "Pending Install" to mark packages that are somewhere in the whole process. refs #828 refs #1357
This commit is contained in:
parent
bda755584f
commit
a1edfdfc8d
@ -485,6 +485,7 @@ public class AppDetails2 extends AppCompatActivity
|
||||
}
|
||||
|
||||
switch (newStatus.status) {
|
||||
case PendingInstall:
|
||||
case Downloading:
|
||||
if (newStatus.progressMax == 0) {
|
||||
// The first progress notification we get telling us our status is "Downloading"
|
||||
|
@ -91,13 +91,14 @@ public final class AppUpdateStatusManager {
|
||||
private static final String LOGTAG = "AppUpdateStatusManager";
|
||||
|
||||
public enum Status {
|
||||
PendingInstall,
|
||||
DownloadInterrupted,
|
||||
UpdateAvailable,
|
||||
Downloading,
|
||||
ReadyToInstall,
|
||||
Installing,
|
||||
Installed,
|
||||
InstallError
|
||||
InstallError,
|
||||
}
|
||||
|
||||
public static AppUpdateStatusManager getInstance(Context context) {
|
||||
|
@ -230,6 +230,7 @@ class NotificationHelper {
|
||||
case UpdateAvailable:
|
||||
return new NotificationCompat.Action(R.drawable.ic_file_download, context.getString(R.string.notification_action_update), entry.intent);
|
||||
|
||||
case PendingInstall:
|
||||
case Downloading:
|
||||
case Installing:
|
||||
return new NotificationCompat.Action(R.drawable.ic_cancel, context.getString(R.string.notification_action_cancel), entry.intent);
|
||||
@ -245,6 +246,7 @@ class NotificationHelper {
|
||||
switch (status) {
|
||||
case UpdateAvailable:
|
||||
return context.getString(R.string.notification_title_single_update_available);
|
||||
case PendingInstall:
|
||||
case Downloading:
|
||||
return app.name;
|
||||
case ReadyToInstall:
|
||||
@ -263,6 +265,7 @@ class NotificationHelper {
|
||||
switch (status) {
|
||||
case UpdateAvailable:
|
||||
return app.name;
|
||||
case PendingInstall:
|
||||
case Downloading:
|
||||
return context.getString(app.isInstalled(context) ? R.string.notification_content_single_downloading_update : R.string.notification_content_single_downloading, app.name);
|
||||
case ReadyToInstall:
|
||||
@ -281,6 +284,7 @@ class NotificationHelper {
|
||||
switch (status) {
|
||||
case UpdateAvailable:
|
||||
return context.getString(R.string.notification_title_summary_update_available);
|
||||
case PendingInstall:
|
||||
case Downloading:
|
||||
return context.getString(app.isInstalled(context) ? R.string.notification_title_summary_downloading_update : R.string.notification_title_summary_downloading);
|
||||
case ReadyToInstall:
|
||||
|
@ -145,7 +145,6 @@ public class FileInstallerActivity extends FragmentActivity {
|
||||
|
||||
private void installPackage(Uri localApkUri, Uri downloadUri, Apk apk) {
|
||||
Utils.debugLog(TAG, "Installing: " + localApkUri.getPath());
|
||||
installer.sendBroadcastInstall(downloadUri, Installer.ACTION_INSTALL_STARTED);
|
||||
File path = apk.getMediaInstallPath(activity.getApplicationContext());
|
||||
path.mkdirs();
|
||||
try {
|
||||
|
@ -34,7 +34,13 @@ import java.io.IOException;
|
||||
/**
|
||||
* Manages the whole process when a background update triggers an install or the user
|
||||
* requests an APK to be installed. It handles checking whether the APK is cached,
|
||||
* downloading it, putting up and maintaining a {@link Notification}, and more.
|
||||
* downloading it, putting up and maintaining a {@link Notification}, and more. This
|
||||
* {@code Service} tracks packages that are in the process as "Pending Installs".
|
||||
* Then {@link DownloaderService} and {@link InstallerService} individually track
|
||||
* packages for those phases of the whole install process. Each of those
|
||||
* {@code Services} have their own related events. For tracking status during the
|
||||
* whole process, {@link AppUpdateStatusManager} tracks the status as represented by
|
||||
* {@link AppUpdateStatusManager.AppUpdateStatus}.
|
||||
* <p>
|
||||
* The {@link App} and {@link Apk} instances are sent via
|
||||
* {@link Intent#putExtra(String, android.os.Bundle)}
|
||||
@ -103,7 +109,6 @@ public class InstallManagerService extends Service {
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
Utils.debugLog(TAG, "creating Service");
|
||||
localBroadcastManager = LocalBroadcastManager.getInstance(this);
|
||||
appUpdateStatusManager = AppUpdateStatusManager.getInstance(this);
|
||||
|
||||
@ -455,14 +460,12 @@ public class InstallManagerService extends Service {
|
||||
*/
|
||||
public static void queue(Context context, App app, @NonNull Apk apk) {
|
||||
String urlString = apk.getUrl();
|
||||
AppUpdateStatusManager.getInstance(context).addApk(apk, AppUpdateStatusManager.Status.PendingInstall, null);
|
||||
putPendingInstall(context, urlString, apk.packageName);
|
||||
Uri downloadUri = Uri.parse(urlString);
|
||||
Installer.sendBroadcastInstall(context, downloadUri, Installer.ACTION_INSTALL_STARTED, apk,
|
||||
null, null);
|
||||
Utils.debugLog(TAG, "queue " + app.packageName + " " + apk.versionCode + " from " + urlString);
|
||||
Intent intent = new Intent(context, InstallManagerService.class);
|
||||
intent.setAction(ACTION_INSTALL);
|
||||
intent.setData(downloadUri);
|
||||
intent.setData(Uri.parse(urlString));
|
||||
intent.putExtra(EXTRA_APP, app);
|
||||
intent.putExtra(EXTRA_APK, apk);
|
||||
context.startService(intent);
|
||||
|
@ -115,6 +115,8 @@ public class InstallerService extends JobIntentService {
|
||||
* @see #uninstall(Context, Apk)
|
||||
*/
|
||||
public static void install(Context context, Uri localApkUri, Uri downloadUri, Apk apk) {
|
||||
Installer.sendBroadcastInstall(context, downloadUri, Installer.ACTION_INSTALL_STARTED, apk,
|
||||
null, null);
|
||||
Intent intent = new Intent(context, InstallerService.class);
|
||||
intent.setAction(ACTION_INSTALL);
|
||||
intent.setData(localApkUri);
|
||||
|
@ -332,6 +332,7 @@ public abstract class AppListItemController extends RecyclerView.ViewHolder {
|
||||
case ReadyToInstall:
|
||||
return getViewStateReadyToInstall(app);
|
||||
|
||||
case PendingInstall:
|
||||
case Downloading:
|
||||
return getViewStateDownloading(app, appStatus);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user