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) {
|
switch (newStatus.status) {
|
||||||
|
case PendingInstall:
|
||||||
case Downloading:
|
case Downloading:
|
||||||
if (newStatus.progressMax == 0) {
|
if (newStatus.progressMax == 0) {
|
||||||
// The first progress notification we get telling us our status is "Downloading"
|
// 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";
|
private static final String LOGTAG = "AppUpdateStatusManager";
|
||||||
|
|
||||||
public enum Status {
|
public enum Status {
|
||||||
|
PendingInstall,
|
||||||
DownloadInterrupted,
|
DownloadInterrupted,
|
||||||
UpdateAvailable,
|
UpdateAvailable,
|
||||||
Downloading,
|
Downloading,
|
||||||
ReadyToInstall,
|
ReadyToInstall,
|
||||||
Installing,
|
Installing,
|
||||||
Installed,
|
Installed,
|
||||||
InstallError
|
InstallError,
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AppUpdateStatusManager getInstance(Context context) {
|
public static AppUpdateStatusManager getInstance(Context context) {
|
||||||
|
@ -230,6 +230,7 @@ class NotificationHelper {
|
|||||||
case UpdateAvailable:
|
case UpdateAvailable:
|
||||||
return new NotificationCompat.Action(R.drawable.ic_file_download, context.getString(R.string.notification_action_update), entry.intent);
|
return new NotificationCompat.Action(R.drawable.ic_file_download, context.getString(R.string.notification_action_update), entry.intent);
|
||||||
|
|
||||||
|
case PendingInstall:
|
||||||
case Downloading:
|
case Downloading:
|
||||||
case Installing:
|
case Installing:
|
||||||
return new NotificationCompat.Action(R.drawable.ic_cancel, context.getString(R.string.notification_action_cancel), entry.intent);
|
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) {
|
switch (status) {
|
||||||
case UpdateAvailable:
|
case UpdateAvailable:
|
||||||
return context.getString(R.string.notification_title_single_update_available);
|
return context.getString(R.string.notification_title_single_update_available);
|
||||||
|
case PendingInstall:
|
||||||
case Downloading:
|
case Downloading:
|
||||||
return app.name;
|
return app.name;
|
||||||
case ReadyToInstall:
|
case ReadyToInstall:
|
||||||
@ -263,6 +265,7 @@ class NotificationHelper {
|
|||||||
switch (status) {
|
switch (status) {
|
||||||
case UpdateAvailable:
|
case UpdateAvailable:
|
||||||
return app.name;
|
return app.name;
|
||||||
|
case PendingInstall:
|
||||||
case Downloading:
|
case Downloading:
|
||||||
return context.getString(app.isInstalled(context) ? R.string.notification_content_single_downloading_update : R.string.notification_content_single_downloading, app.name);
|
return context.getString(app.isInstalled(context) ? R.string.notification_content_single_downloading_update : R.string.notification_content_single_downloading, app.name);
|
||||||
case ReadyToInstall:
|
case ReadyToInstall:
|
||||||
@ -281,6 +284,7 @@ class NotificationHelper {
|
|||||||
switch (status) {
|
switch (status) {
|
||||||
case UpdateAvailable:
|
case UpdateAvailable:
|
||||||
return context.getString(R.string.notification_title_summary_update_available);
|
return context.getString(R.string.notification_title_summary_update_available);
|
||||||
|
case PendingInstall:
|
||||||
case Downloading:
|
case Downloading:
|
||||||
return context.getString(app.isInstalled(context) ? R.string.notification_title_summary_downloading_update : R.string.notification_title_summary_downloading);
|
return context.getString(app.isInstalled(context) ? R.string.notification_title_summary_downloading_update : R.string.notification_title_summary_downloading);
|
||||||
case ReadyToInstall:
|
case ReadyToInstall:
|
||||||
|
@ -145,7 +145,6 @@ public class FileInstallerActivity extends FragmentActivity {
|
|||||||
|
|
||||||
private void installPackage(Uri localApkUri, Uri downloadUri, Apk apk) {
|
private void installPackage(Uri localApkUri, Uri downloadUri, Apk apk) {
|
||||||
Utils.debugLog(TAG, "Installing: " + localApkUri.getPath());
|
Utils.debugLog(TAG, "Installing: " + localApkUri.getPath());
|
||||||
installer.sendBroadcastInstall(downloadUri, Installer.ACTION_INSTALL_STARTED);
|
|
||||||
File path = apk.getMediaInstallPath(activity.getApplicationContext());
|
File path = apk.getMediaInstallPath(activity.getApplicationContext());
|
||||||
path.mkdirs();
|
path.mkdirs();
|
||||||
try {
|
try {
|
||||||
|
@ -34,7 +34,13 @@ import java.io.IOException;
|
|||||||
/**
|
/**
|
||||||
* Manages the whole process when a background update triggers an install or the user
|
* 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,
|
* 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>
|
* <p>
|
||||||
* The {@link App} and {@link Apk} instances are sent via
|
* The {@link App} and {@link Apk} instances are sent via
|
||||||
* {@link Intent#putExtra(String, android.os.Bundle)}
|
* {@link Intent#putExtra(String, android.os.Bundle)}
|
||||||
@ -103,7 +109,6 @@ public class InstallManagerService extends Service {
|
|||||||
@Override
|
@Override
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
Utils.debugLog(TAG, "creating Service");
|
|
||||||
localBroadcastManager = LocalBroadcastManager.getInstance(this);
|
localBroadcastManager = LocalBroadcastManager.getInstance(this);
|
||||||
appUpdateStatusManager = AppUpdateStatusManager.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) {
|
public static void queue(Context context, App app, @NonNull Apk apk) {
|
||||||
String urlString = apk.getUrl();
|
String urlString = apk.getUrl();
|
||||||
|
AppUpdateStatusManager.getInstance(context).addApk(apk, AppUpdateStatusManager.Status.PendingInstall, null);
|
||||||
putPendingInstall(context, urlString, apk.packageName);
|
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);
|
Utils.debugLog(TAG, "queue " + app.packageName + " " + apk.versionCode + " from " + urlString);
|
||||||
Intent intent = new Intent(context, InstallManagerService.class);
|
Intent intent = new Intent(context, InstallManagerService.class);
|
||||||
intent.setAction(ACTION_INSTALL);
|
intent.setAction(ACTION_INSTALL);
|
||||||
intent.setData(downloadUri);
|
intent.setData(Uri.parse(urlString));
|
||||||
intent.putExtra(EXTRA_APP, app);
|
intent.putExtra(EXTRA_APP, app);
|
||||||
intent.putExtra(EXTRA_APK, apk);
|
intent.putExtra(EXTRA_APK, apk);
|
||||||
context.startService(intent);
|
context.startService(intent);
|
||||||
|
@ -115,6 +115,8 @@ public class InstallerService extends JobIntentService {
|
|||||||
* @see #uninstall(Context, Apk)
|
* @see #uninstall(Context, Apk)
|
||||||
*/
|
*/
|
||||||
public static void install(Context context, Uri localApkUri, Uri downloadUri, Apk 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 intent = new Intent(context, InstallerService.class);
|
||||||
intent.setAction(ACTION_INSTALL);
|
intent.setAction(ACTION_INSTALL);
|
||||||
intent.setData(localApkUri);
|
intent.setData(localApkUri);
|
||||||
|
@ -332,6 +332,7 @@ public abstract class AppListItemController extends RecyclerView.ViewHolder {
|
|||||||
case ReadyToInstall:
|
case ReadyToInstall:
|
||||||
return getViewStateReadyToInstall(app);
|
return getViewStateReadyToInstall(app);
|
||||||
|
|
||||||
|
case PendingInstall:
|
||||||
case Downloading:
|
case Downloading:
|
||||||
return getViewStateDownloading(app, appStatus);
|
return getViewStateDownloading(app, appStatus);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user