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:
@@ -35,7 +35,11 @@
|
|||||||
<service android:name=".controller.UpdaterService" />
|
<service android:name=".controller.UpdaterService" />
|
||||||
<service android:name=".ExportUpdateService" />
|
<service android:name=".ExportUpdateService" />
|
||||||
|
|
||||||
<receiver android:name=".UpdaterReceiver" android:exported="false" />
|
<receiver android:name=".UpdaterReceiver" android:exported="false">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.BOOT_COMPLETED"/>
|
||||||
|
</intent-filter>
|
||||||
|
</receiver>
|
||||||
|
|
||||||
<receiver android:name=".UpdatesCheckReceiver">
|
<receiver android:name=".UpdatesCheckReceiver">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
|
@@ -18,7 +18,11 @@ package org.lineageos.updater;
|
|||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
import android.os.PowerManager;
|
import android.os.PowerManager;
|
||||||
|
import android.support.v7.preference.PreferenceManager;
|
||||||
|
|
||||||
|
import org.lineageos.updater.misc.Constants;
|
||||||
|
|
||||||
public class UpdaterReceiver extends BroadcastReceiver {
|
public class UpdaterReceiver extends BroadcastReceiver {
|
||||||
|
|
||||||
@@ -30,6 +34,9 @@ public class UpdaterReceiver extends BroadcastReceiver {
|
|||||||
if (ACTION_INSTALL_REBOOT.equals(intent.getAction())) {
|
if (ACTION_INSTALL_REBOOT.equals(intent.getAction())) {
|
||||||
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
|
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
|
||||||
pm.reboot(null);
|
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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -42,7 +42,6 @@ class ABUpdateInstaller {
|
|||||||
private static final String TAG = "ABUpdateInstaller";
|
private static final String TAG = "ABUpdateInstaller";
|
||||||
|
|
||||||
private static final String PREF_INSTALLING_AB_ID = "installing_ab_id";
|
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;
|
private static ABUpdateInstaller sInstance = null;
|
||||||
|
|
||||||
@@ -119,13 +118,13 @@ class ABUpdateInstaller {
|
|||||||
static synchronized boolean isInstallingUpdate(Context context) {
|
static synchronized boolean isInstallingUpdate(Context context) {
|
||||||
SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context);
|
SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
return pref.getString(ABUpdateInstaller.PREF_INSTALLING_AB_ID, null) != null ||
|
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) {
|
static synchronized boolean isInstallingUpdate(Context context, String downloadId) {
|
||||||
SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context);
|
SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
return downloadId.equals(pref.getString(ABUpdateInstaller.PREF_INSTALLING_AB_ID, null)) ||
|
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) {
|
private ABUpdateInstaller(Context context, UpdaterController updaterController) {
|
||||||
@@ -233,7 +232,7 @@ class ABUpdateInstaller {
|
|||||||
|
|
||||||
private void installationDone(boolean needsReboot) {
|
private void installationDone(boolean needsReboot) {
|
||||||
PreferenceManager.getDefaultSharedPreferences(mContext).edit()
|
PreferenceManager.getDefaultSharedPreferences(mContext).edit()
|
||||||
.putBoolean(PREF_NEEDS_REBOOT, needsReboot)
|
.putBoolean(Constants.PREF_NEEDS_REBOOT, needsReboot)
|
||||||
.remove(PREF_INSTALLING_AB_ID)
|
.remove(PREF_INSTALLING_AB_ID)
|
||||||
.apply();
|
.apply();
|
||||||
}
|
}
|
||||||
|
@@ -27,6 +27,7 @@ public final class Constants {
|
|||||||
public static final String PREF_AUTO_UPDATES_CHECK = "auto_updates_check";
|
public static final String PREF_AUTO_UPDATES_CHECK = "auto_updates_check";
|
||||||
public static final String PREF_AUTO_DELETE_UPDATES = "auto_delete_updates";
|
public static final String PREF_AUTO_DELETE_UPDATES = "auto_delete_updates";
|
||||||
public static final String PREF_MOBILE_DATA_WARNING = "pref_mobile_data_warning";
|
public static final String PREF_MOBILE_DATA_WARNING = "pref_mobile_data_warning";
|
||||||
|
public static final String PREF_NEEDS_REBOOT = "needs_reboot";
|
||||||
|
|
||||||
public static final String UNCRYPT_FILE_EXT = ".uncrypt";
|
public static final String UNCRYPT_FILE_EXT = ".uncrypt";
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user