Loading app/src/main/java/org/lineageos/updater/UpdaterReceiver.java +2 −2 Original line number Diff line number Diff line Loading @@ -88,13 +88,13 @@ public class UpdaterReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { if (ACTION_INSTALL_REBOOT.equals(intent.getAction())) { Utils.removeInstalledUpdate(context); Utils.removeInstalledUpdates(context); PowerManager pm = context.getSystemService(PowerManager.class); pm.reboot(null); } else if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) { SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context); pref.edit().remove(Constants.PREF_NEEDS_REBOOT_ID).apply(); Utils.removeInstalledUpdate(context); Utils.removeInstalledUpdates(context); if (shouldShowUpdateFailedNotification(context)) { pref.edit().putBoolean(Constants.PREF_INSTALL_NOTIFIED, true).apply(); Loading app/src/main/java/org/lineageos/updater/misc/Utils.java +20 −4 Original line number Diff line number Diff line Loading @@ -59,6 +59,7 @@ import org.lineageos.updater.controller.UpdaterService; import org.lineageos.updater.model.Update; import org.lineageos.updater.model.UpdateBaseInfo; import org.lineageos.updater.model.UpdateInfo; import org.lineageos.updater.model.UpdateStatus; import java.io.BufferedReader; import java.io.File; Loading Loading @@ -485,13 +486,28 @@ public class Utils { preferences.edit().putBoolean(DOWNLOADS_CLEANUP_DONE, true).apply(); } public static void removeInstalledUpdate(Context context) { public static void removeInstalledUpdates(Context context) { SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context); String downloadId = pref.getString(Constants.PREF_NEEDS_DELETE_ID, null); boolean deleteUpdate = pref.getBoolean(Constants.PREF_AUTO_DELETE_UPDATES, true); if (!deleteUpdate) return; UpdaterController controller = UpdaterController.getInstance(context); if (controller != null && downloadId != null) { controller.deleteUpdate(downloadId); if (controller == null) return; // Remove update ID if it exists String downloadId = pref.getString(Constants.PREF_NEEDS_DELETE_ID, null); if (downloadId != null) { pref.edit().remove(Constants.PREF_NEEDS_DELETE_ID).apply(); controller.deleteUpdate(downloadId); } // Remove all installed updates List<UpdateInfo> updates = controller.getUpdates(); if (updates == null || updates.isEmpty()) return; for (UpdateInfo update : updates) { if (update != null && update.getStatus() == UpdateStatus.INSTALLED) { controller.deleteUpdate(update.getDownloadId()); } } } Loading Loading
app/src/main/java/org/lineageos/updater/UpdaterReceiver.java +2 −2 Original line number Diff line number Diff line Loading @@ -88,13 +88,13 @@ public class UpdaterReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { if (ACTION_INSTALL_REBOOT.equals(intent.getAction())) { Utils.removeInstalledUpdate(context); Utils.removeInstalledUpdates(context); PowerManager pm = context.getSystemService(PowerManager.class); pm.reboot(null); } else if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) { SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context); pref.edit().remove(Constants.PREF_NEEDS_REBOOT_ID).apply(); Utils.removeInstalledUpdate(context); Utils.removeInstalledUpdates(context); if (shouldShowUpdateFailedNotification(context)) { pref.edit().putBoolean(Constants.PREF_INSTALL_NOTIFIED, true).apply(); Loading
app/src/main/java/org/lineageos/updater/misc/Utils.java +20 −4 Original line number Diff line number Diff line Loading @@ -59,6 +59,7 @@ import org.lineageos.updater.controller.UpdaterService; import org.lineageos.updater.model.Update; import org.lineageos.updater.model.UpdateBaseInfo; import org.lineageos.updater.model.UpdateInfo; import org.lineageos.updater.model.UpdateStatus; import java.io.BufferedReader; import java.io.File; Loading Loading @@ -485,13 +486,28 @@ public class Utils { preferences.edit().putBoolean(DOWNLOADS_CLEANUP_DONE, true).apply(); } public static void removeInstalledUpdate(Context context) { public static void removeInstalledUpdates(Context context) { SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context); String downloadId = pref.getString(Constants.PREF_NEEDS_DELETE_ID, null); boolean deleteUpdate = pref.getBoolean(Constants.PREF_AUTO_DELETE_UPDATES, true); if (!deleteUpdate) return; UpdaterController controller = UpdaterController.getInstance(context); if (controller != null && downloadId != null) { controller.deleteUpdate(downloadId); if (controller == null) return; // Remove update ID if it exists String downloadId = pref.getString(Constants.PREF_NEEDS_DELETE_ID, null); if (downloadId != null) { pref.edit().remove(Constants.PREF_NEEDS_DELETE_ID).apply(); controller.deleteUpdate(downloadId); } // Remove all installed updates List<UpdateInfo> updates = controller.getUpdates(); if (updates == null || updates.isEmpty()) return; for (UpdateInfo update : updates) { if (update != null && update.getStatus() == UpdateStatus.INSTALLED) { controller.deleteUpdate(update.getDownloadId()); } } } Loading