Loading src/org/lineageos/updater/UpdaterReceiver.java +4 −8 Original line number Diff line number Diff line Loading @@ -28,10 +28,10 @@ import android.os.SystemProperties; import androidx.core.app.NotificationCompat; import androidx.preference.PreferenceManager; import org.lineageos.updater.controller.UpdaterController; import org.lineageos.updater.misc.BuildInfoUtils; import org.lineageos.updater.misc.Constants; import org.lineageos.updater.misc.StringGenerator; import org.lineageos.updater.misc.Utils; import java.text.DateFormat; Loading Loading @@ -87,18 +87,14 @@ public class UpdaterReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context); if (ACTION_INSTALL_REBOOT.equals(intent.getAction())) { String downloadId = pref.getString(Constants.PREF_NEEDS_DELETE_ID, null); UpdaterController controller = UpdaterController.getInstance(context); if (controller != null && downloadId != null) { controller.deleteUpdate(downloadId); } Utils.removeInstalledUpdate(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(); pref.edit().remove(Constants.PREF_NEEDS_DELETE_ID).apply(); Utils.removeInstalledUpdate(context); if (shouldShowUpdateFailedNotification(context)) { pref.edit().putBoolean(Constants.PREF_INSTALL_NOTIFIED, true).apply(); Loading src/org/lineageos/updater/misc/Utils.java +11 −0 Original line number Diff line number Diff line Loading @@ -54,6 +54,7 @@ import org.json.JSONException; import org.json.JSONObject; import org.lineageos.updater.R; import org.lineageos.updater.UpdatesDbHelper; import org.lineageos.updater.controller.UpdaterController; import org.lineageos.updater.controller.UpdaterService; import org.lineageos.updater.model.Update; import org.lineageos.updater.model.UpdateBaseInfo; Loading Loading @@ -490,6 +491,16 @@ public class Utils { preferences.edit().putBoolean(DOWNLOADS_CLEANUP_DONE, true).apply(); } public static void removeInstalledUpdate(Context context) { SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context); String downloadId = pref.getString(Constants.PREF_NEEDS_DELETE_ID, null); UpdaterController controller = UpdaterController.getInstance(context); if (controller != null && downloadId != null) { controller.deleteUpdate(downloadId); pref.edit().remove(Constants.PREF_NEEDS_DELETE_ID).apply(); } } public static File appendSequentialNumber(final File file) { String name; String extension; Loading Loading
src/org/lineageos/updater/UpdaterReceiver.java +4 −8 Original line number Diff line number Diff line Loading @@ -28,10 +28,10 @@ import android.os.SystemProperties; import androidx.core.app.NotificationCompat; import androidx.preference.PreferenceManager; import org.lineageos.updater.controller.UpdaterController; import org.lineageos.updater.misc.BuildInfoUtils; import org.lineageos.updater.misc.Constants; import org.lineageos.updater.misc.StringGenerator; import org.lineageos.updater.misc.Utils; import java.text.DateFormat; Loading Loading @@ -87,18 +87,14 @@ public class UpdaterReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context); if (ACTION_INSTALL_REBOOT.equals(intent.getAction())) { String downloadId = pref.getString(Constants.PREF_NEEDS_DELETE_ID, null); UpdaterController controller = UpdaterController.getInstance(context); if (controller != null && downloadId != null) { controller.deleteUpdate(downloadId); } Utils.removeInstalledUpdate(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(); pref.edit().remove(Constants.PREF_NEEDS_DELETE_ID).apply(); Utils.removeInstalledUpdate(context); if (shouldShowUpdateFailedNotification(context)) { pref.edit().putBoolean(Constants.PREF_INSTALL_NOTIFIED, true).apply(); Loading
src/org/lineageos/updater/misc/Utils.java +11 −0 Original line number Diff line number Diff line Loading @@ -54,6 +54,7 @@ import org.json.JSONException; import org.json.JSONObject; import org.lineageos.updater.R; import org.lineageos.updater.UpdatesDbHelper; import org.lineageos.updater.controller.UpdaterController; import org.lineageos.updater.controller.UpdaterService; import org.lineageos.updater.model.Update; import org.lineageos.updater.model.UpdateBaseInfo; Loading Loading @@ -490,6 +491,16 @@ public class Utils { preferences.edit().putBoolean(DOWNLOADS_CLEANUP_DONE, true).apply(); } public static void removeInstalledUpdate(Context context) { SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context); String downloadId = pref.getString(Constants.PREF_NEEDS_DELETE_ID, null); UpdaterController controller = UpdaterController.getInstance(context); if (controller != null && downloadId != null) { controller.deleteUpdate(downloadId); pref.edit().remove(Constants.PREF_NEEDS_DELETE_ID).apply(); } } public static File appendSequentialNumber(final File file) { String name; String extension; Loading