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