Don't register multiple UpdateEngine callbacks
We are loosely tied to UpdateEngine and have no way to know whether we are bound or not without keeping track of the connection manually. Since UpdaterService is for both A/B and legacy updates, turn ABUpdateInstaller into a singleton to keep the code simple while ensuring that a single callback is registered. Change-Id: Ib4e9ad1413ba96bf5ed59cc3383741b5c9bac427
This commit is contained in:
@@ -155,7 +155,7 @@ public class UpdaterService extends Service {
|
||||
if ((intent == null || intent.getAction() == null) &&
|
||||
ABUpdateInstaller.isInstallingUpdate(this)) {
|
||||
// The service is being restarted.
|
||||
ABUpdateInstaller installer = new ABUpdateInstaller(this, mUpdaterController);
|
||||
ABUpdateInstaller installer = ABUpdateInstaller.getInstance(this, mUpdaterController);
|
||||
if (installer.reconnect()) {
|
||||
return START_STICKY;
|
||||
}
|
||||
@@ -177,7 +177,8 @@ public class UpdaterService extends Service {
|
||||
}
|
||||
try {
|
||||
if (Utils.isABUpdate(update.getFile())) {
|
||||
ABUpdateInstaller installer = new ABUpdateInstaller(this, mUpdaterController);
|
||||
ABUpdateInstaller installer = ABUpdateInstaller.getInstance(this,
|
||||
mUpdaterController);
|
||||
if (installer.install(downloadId)) {
|
||||
return START_STICKY;
|
||||
}
|
||||
@@ -196,7 +197,8 @@ public class UpdaterService extends Service {
|
||||
UpdateInstaller installer = new UpdateInstaller(this, mUpdaterController);
|
||||
installer.cancel();
|
||||
} else if (ABUpdateInstaller.isInstallingUpdate(this)) {
|
||||
ABUpdateInstaller installer = new ABUpdateInstaller(this, mUpdaterController);
|
||||
ABUpdateInstaller installer = ABUpdateInstaller.getInstance(this,
|
||||
mUpdaterController);
|
||||
installer.reconnect();
|
||||
installer.cancel();
|
||||
}
|
||||
|
Reference in New Issue
Block a user