Clear NEEDS_REBOOT preference on reboot

UpdateEngine doesn't send an initial notification to bound client
if the last status is not known, so clear the preference when we
detect that the device has been rebooted.

Change-Id: Ib15dff5fa8ac9ec07a68018a83683cc561fd3e85
This commit is contained in:
Gabriele M
2018-03-24 16:17:19 +01:00
parent fa5f24ac3f
commit c34c266513
4 changed files with 16 additions and 5 deletions

View File

@@ -42,7 +42,6 @@ class ABUpdateInstaller {
private static final String TAG = "ABUpdateInstaller";
private static final String PREF_INSTALLING_AB_ID = "installing_ab_id";
private static final String PREF_NEEDS_REBOOT = "needs_reboot";
private static ABUpdateInstaller sInstance = null;
@@ -119,13 +118,13 @@ class ABUpdateInstaller {
static synchronized boolean isInstallingUpdate(Context context) {
SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context);
return pref.getString(ABUpdateInstaller.PREF_INSTALLING_AB_ID, null) != null ||
pref.getBoolean(ABUpdateInstaller.PREF_NEEDS_REBOOT, false);
pref.getBoolean(Constants.PREF_NEEDS_REBOOT, false);
}
static synchronized boolean isInstallingUpdate(Context context, String downloadId) {
SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context);
return downloadId.equals(pref.getString(ABUpdateInstaller.PREF_INSTALLING_AB_ID, null)) ||
pref.getBoolean(ABUpdateInstaller.PREF_NEEDS_REBOOT, false);
pref.getBoolean(Constants.PREF_NEEDS_REBOOT, false);
}
private ABUpdateInstaller(Context context, UpdaterController updaterController) {
@@ -233,7 +232,7 @@ class ABUpdateInstaller {
private void installationDone(boolean needsReboot) {
PreferenceManager.getDefaultSharedPreferences(mContext).edit()
.putBoolean(PREF_NEEDS_REBOOT, needsReboot)
.putBoolean(Constants.PREF_NEEDS_REBOOT, needsReboot)
.remove(PREF_INSTALLING_AB_ID)
.apply();
}