Loading res/values/strings.xml +2 −0 Original line number Original line Diff line number Diff line Loading @@ -53,6 +53,7 @@ <string name="pause_button">Pause</string> <string name="pause_button">Pause</string> <string name="resume_button">Resume</string> <string name="resume_button">Resume</string> <string name="suspend_button">Suspend</string> <string name="suspend_button">Suspend</string> <string name="reboot_install">Reboot and install</string> <string name="installing_update">Installing update package</string> <string name="installing_update">Installing update package</string> <string name="installing_update_error">Install error</string> <string name="installing_update_error">Install error</string> Loading Loading @@ -108,6 +109,7 @@ <string name="list_no_updates">You are running the latest /e/OS version. To manually check for updates, use the Refresh button.</string> <string name="list_no_updates">You are running the latest /e/OS version. To manually check for updates, use the Refresh button.</string> <string name="action_download">Download</string> <string name="action_download">Download</string> <string name="action_update">Apply update</string> <string name="action_pause">Pause</string> <string name="action_pause">Pause</string> <string name="action_resume">Resume</string> <string name="action_resume">Resume</string> <string name="action_install">Install</string> <string name="action_install">Install</string> Loading src/org/lineageos/updater/UpdatesListAdapter.java +6 −3 Original line number Original line Diff line number Diff line Loading @@ -250,7 +250,8 @@ public class UpdatesListAdapter extends RecyclerView.Adapter<UpdatesListAdapter. if (update == null) { if (update == null) { // The update was deleted // The update was deleted viewHolder.mAction.setEnabled(false); viewHolder.mAction.setEnabled(false); viewHolder.mAction.setText(R.string.action_download); viewHolder.mAction.setText(Utils.isABDevice() ? R.string.action_update : R.string.action_download); return; return; } } Loading Loading @@ -358,7 +359,8 @@ public class UpdatesListAdapter extends RecyclerView.Adapter<UpdatesListAdapter. .setTitle(R.string.update_on_mobile_data_title) .setTitle(R.string.update_on_mobile_data_title) .setMessage(R.string.update_on_mobile_data_message) .setMessage(R.string.update_on_mobile_data_message) .setView(checkboxView) .setView(checkboxView) .setPositiveButton(R.string.action_download, .setPositiveButton(Utils.isABDevice() ? R.string.action_update : R.string.action_download, (dialog, which) -> { (dialog, which) -> { if (checkbox.isChecked()) { if (checkbox.isChecked()) { preferences.edit() preferences.edit() Loading @@ -377,7 +379,8 @@ public class UpdatesListAdapter extends RecyclerView.Adapter<UpdatesListAdapter. final View.OnClickListener clickListener; final View.OnClickListener clickListener; switch (action) { switch (action) { case DOWNLOAD: case DOWNLOAD: button.setText(R.string.action_download); button.setText(Utils.isABDevice() ? R.string.action_update : R.string.action_download); button.setEnabled(enabled); button.setEnabled(enabled); clickListener = enabled ? view -> { clickListener = enabled ? view -> { AlertDialog.Builder freeSpaceDialog = getSpaceDialog( AlertDialog.Builder freeSpaceDialog = getSpaceDialog( Loading src/org/lineageos/updater/controller/UpdaterService.java +42 −1 Original line number Original line Diff line number Diff line Loading @@ -346,12 +346,45 @@ public class UpdaterService extends Service { mNotificationBuilder.setSmallIcon(R.drawable.ic_system_update); mNotificationBuilder.setSmallIcon(R.drawable.ic_system_update); mNotificationBuilder.setProgress(0, 0, false); mNotificationBuilder.setProgress(0, 0, false); String text = getString(R.string.download_completed_notification); String text = getString(R.string.download_completed_notification); boolean hasRequiredSpace = Utils.availableFreeSpace() > (update.getFileSize() * 2); if (!Utils.canInstall(update) || !Utils.isBatteryLevelOk(this) || !hasRequiredSpace) { /* Show notification if any of the below condition didn't met. */ text = getString(R.string.blocked_update_dialog_title) + ". "; if (!Utils.isBatteryLevelOk(this)) { text = text + getString(R.string.dialog_battery_low_title); } else if (!hasRequiredSpace) { text = text + getString(R.string.dialog_free_space_low_title); } else if (!Utils.canInstall(update)) { text = text + getString(R.string.verification_failed_notification); } } else if (!Utils.isABDevice()) { /* Add action to reboot and install for Non-A/B devices. */ mNotificationBuilder.mActions.clear(); mNotificationBuilder.addAction(R.drawable.ic_system_update, getString(R.string.reboot_install), getInstallationPendingIntent(update.getDownloadId())); } mNotificationBuilder.setContentText(text); mNotificationBuilder.setContentText(text); mNotificationBuilder.setTicker(text); mNotificationBuilder.setTicker(text); mNotificationBuilder.setOngoing(false); mNotificationBuilder.setOngoing(false); mNotificationBuilder.setAutoCancel(true); mNotificationBuilder.setAutoCancel(true); mNotificationManager.notify(NOTIFICATION_ID, mNotificationBuilder.build()); mNotificationManager.notify(NOTIFICATION_ID, mNotificationBuilder.build()); /* Make sure these conditions are met before auto install - Can install package (Is a newer build or downgrade allowed) - Battery level (Above 30% if discharging or 20% if charging) - Free space to install (Double the size of the ota zip) */ if (Utils.isABDevice() && Utils.canInstall(update) && Utils.isBatteryLevelOk(this) && hasRequiredSpace) { Utils.triggerUpdate(this, update.getDownloadId()); } else { tryStopSelf(); tryStopSelf(); } break; break; } } case VERIFICATION_FAILED: { case VERIFICATION_FAILED: { Loading Loading @@ -528,6 +561,14 @@ public class UpdaterService extends Service { PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE); PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE); } } private PendingIntent getInstallationPendingIntent(String downloadId) { final Intent intent = new Intent(this, UpdaterService.class); intent.setAction(ACTION_INSTALL_UPDATE); intent.putExtra(UpdaterService.EXTRA_DOWNLOAD_ID, downloadId); return PendingIntent.getService(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE); } private PendingIntent getResumeInstallationPendingIntent() { private PendingIntent getResumeInstallationPendingIntent() { final Intent intent = new Intent(this, UpdaterService.class); final Intent intent = new Intent(this, UpdaterService.class); intent.setAction(ACTION_INSTALL_RESUME); intent.setAction(ACTION_INSTALL_RESUME); Loading Loading
res/values/strings.xml +2 −0 Original line number Original line Diff line number Diff line Loading @@ -53,6 +53,7 @@ <string name="pause_button">Pause</string> <string name="pause_button">Pause</string> <string name="resume_button">Resume</string> <string name="resume_button">Resume</string> <string name="suspend_button">Suspend</string> <string name="suspend_button">Suspend</string> <string name="reboot_install">Reboot and install</string> <string name="installing_update">Installing update package</string> <string name="installing_update">Installing update package</string> <string name="installing_update_error">Install error</string> <string name="installing_update_error">Install error</string> Loading Loading @@ -108,6 +109,7 @@ <string name="list_no_updates">You are running the latest /e/OS version. To manually check for updates, use the Refresh button.</string> <string name="list_no_updates">You are running the latest /e/OS version. To manually check for updates, use the Refresh button.</string> <string name="action_download">Download</string> <string name="action_download">Download</string> <string name="action_update">Apply update</string> <string name="action_pause">Pause</string> <string name="action_pause">Pause</string> <string name="action_resume">Resume</string> <string name="action_resume">Resume</string> <string name="action_install">Install</string> <string name="action_install">Install</string> Loading
src/org/lineageos/updater/UpdatesListAdapter.java +6 −3 Original line number Original line Diff line number Diff line Loading @@ -250,7 +250,8 @@ public class UpdatesListAdapter extends RecyclerView.Adapter<UpdatesListAdapter. if (update == null) { if (update == null) { // The update was deleted // The update was deleted viewHolder.mAction.setEnabled(false); viewHolder.mAction.setEnabled(false); viewHolder.mAction.setText(R.string.action_download); viewHolder.mAction.setText(Utils.isABDevice() ? R.string.action_update : R.string.action_download); return; return; } } Loading Loading @@ -358,7 +359,8 @@ public class UpdatesListAdapter extends RecyclerView.Adapter<UpdatesListAdapter. .setTitle(R.string.update_on_mobile_data_title) .setTitle(R.string.update_on_mobile_data_title) .setMessage(R.string.update_on_mobile_data_message) .setMessage(R.string.update_on_mobile_data_message) .setView(checkboxView) .setView(checkboxView) .setPositiveButton(R.string.action_download, .setPositiveButton(Utils.isABDevice() ? R.string.action_update : R.string.action_download, (dialog, which) -> { (dialog, which) -> { if (checkbox.isChecked()) { if (checkbox.isChecked()) { preferences.edit() preferences.edit() Loading @@ -377,7 +379,8 @@ public class UpdatesListAdapter extends RecyclerView.Adapter<UpdatesListAdapter. final View.OnClickListener clickListener; final View.OnClickListener clickListener; switch (action) { switch (action) { case DOWNLOAD: case DOWNLOAD: button.setText(R.string.action_download); button.setText(Utils.isABDevice() ? R.string.action_update : R.string.action_download); button.setEnabled(enabled); button.setEnabled(enabled); clickListener = enabled ? view -> { clickListener = enabled ? view -> { AlertDialog.Builder freeSpaceDialog = getSpaceDialog( AlertDialog.Builder freeSpaceDialog = getSpaceDialog( Loading
src/org/lineageos/updater/controller/UpdaterService.java +42 −1 Original line number Original line Diff line number Diff line Loading @@ -346,12 +346,45 @@ public class UpdaterService extends Service { mNotificationBuilder.setSmallIcon(R.drawable.ic_system_update); mNotificationBuilder.setSmallIcon(R.drawable.ic_system_update); mNotificationBuilder.setProgress(0, 0, false); mNotificationBuilder.setProgress(0, 0, false); String text = getString(R.string.download_completed_notification); String text = getString(R.string.download_completed_notification); boolean hasRequiredSpace = Utils.availableFreeSpace() > (update.getFileSize() * 2); if (!Utils.canInstall(update) || !Utils.isBatteryLevelOk(this) || !hasRequiredSpace) { /* Show notification if any of the below condition didn't met. */ text = getString(R.string.blocked_update_dialog_title) + ". "; if (!Utils.isBatteryLevelOk(this)) { text = text + getString(R.string.dialog_battery_low_title); } else if (!hasRequiredSpace) { text = text + getString(R.string.dialog_free_space_low_title); } else if (!Utils.canInstall(update)) { text = text + getString(R.string.verification_failed_notification); } } else if (!Utils.isABDevice()) { /* Add action to reboot and install for Non-A/B devices. */ mNotificationBuilder.mActions.clear(); mNotificationBuilder.addAction(R.drawable.ic_system_update, getString(R.string.reboot_install), getInstallationPendingIntent(update.getDownloadId())); } mNotificationBuilder.setContentText(text); mNotificationBuilder.setContentText(text); mNotificationBuilder.setTicker(text); mNotificationBuilder.setTicker(text); mNotificationBuilder.setOngoing(false); mNotificationBuilder.setOngoing(false); mNotificationBuilder.setAutoCancel(true); mNotificationBuilder.setAutoCancel(true); mNotificationManager.notify(NOTIFICATION_ID, mNotificationBuilder.build()); mNotificationManager.notify(NOTIFICATION_ID, mNotificationBuilder.build()); /* Make sure these conditions are met before auto install - Can install package (Is a newer build or downgrade allowed) - Battery level (Above 30% if discharging or 20% if charging) - Free space to install (Double the size of the ota zip) */ if (Utils.isABDevice() && Utils.canInstall(update) && Utils.isBatteryLevelOk(this) && hasRequiredSpace) { Utils.triggerUpdate(this, update.getDownloadId()); } else { tryStopSelf(); tryStopSelf(); } break; break; } } case VERIFICATION_FAILED: { case VERIFICATION_FAILED: { Loading Loading @@ -528,6 +561,14 @@ public class UpdaterService extends Service { PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE); PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE); } } private PendingIntent getInstallationPendingIntent(String downloadId) { final Intent intent = new Intent(this, UpdaterService.class); intent.setAction(ACTION_INSTALL_UPDATE); intent.putExtra(UpdaterService.EXTRA_DOWNLOAD_ID, downloadId); return PendingIntent.getService(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE); } private PendingIntent getResumeInstallationPendingIntent() { private PendingIntent getResumeInstallationPendingIntent() { final Intent intent = new Intent(this, UpdaterService.class); final Intent intent = new Intent(this, UpdaterService.class); intent.setAction(ACTION_INSTALL_RESUME); intent.setAction(ACTION_INSTALL_RESUME); Loading