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

@@ -18,7 +18,11 @@ package org.lineageos.updater;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.PowerManager;
import android.support.v7.preference.PreferenceManager;
import org.lineageos.updater.misc.Constants;
public class UpdaterReceiver extends BroadcastReceiver {
@@ -30,6 +34,9 @@ public class UpdaterReceiver extends BroadcastReceiver {
if (ACTION_INSTALL_REBOOT.equals(intent.getAction())) {
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
pm.reboot(null);
} else if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) {
SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context);
pref.edit().remove(Constants.PREF_NEEDS_REBOOT).apply();
}
}
}