Commit 40109a0d authored by Aayush Gupta's avatar Aayush Gupta
Browse files

Merge branch 'aayush_test' into 'v1-q'

[Q] Address backlogs related to Updater

See merge request !36
parents c8b1aafc 5a5b407b
......@@ -11,7 +11,7 @@
android:title="@string/menu_preferences"
app:showAsAction="never" />
<item
android:id="@+id/menu_show_changelog"
android:title="@string/menu_show_changelog"
android:id="@+id/menu_show_release_notes"
android:title="@string/menu_show_release_notes"
app:showAsAction="never" />
</menu>
......@@ -75,7 +75,7 @@
<string name="menu_delete_update">Delete</string>
<string name="menu_copy_url">Copy URL</string>
<string name="menu_export_update">Export update</string>
<string name="menu_show_changelog">Show changelog</string>
<string name="menu_show_release_notes">Show release notes</string>
<string name="menu_changelog_url" translatable="false">https://gitlab.e.foundation/e/os/releases/-/releases/v<xliff:g id="build_version">%1$s</xliff:g>-q</string>
<string name="menu_ab_perf_mode">Prioritize update process</string>
......
......@@ -202,7 +202,7 @@ public class UpdatesActivity extends UpdatesListActivity {
showPreferencesDialog();
return true;
}
case R.id.menu_show_changelog: {
case R.id.menu_show_release_notes: {
Intent openUrl = new Intent(Intent.ACTION_VIEW,
Uri.parse(Utils.getChangelogURL(this)));
startActivity(openUrl);
......@@ -296,7 +296,7 @@ public class UpdatesActivity extends UpdatesListActivity {
preferences.edit().putLong(Constants.PREF_LAST_UPDATE_CHECK, millis).apply();
updateLastCheckedString();
if (json.exists() && Utils.isUpdateCheckEnabled(this) &&
Utils.checkForNewUpdates(json, jsonNew)) {
Utils.checkForNewUpdates(jsonNew)) {
UpdatesCheckReceiver.updateRepeatingUpdatesCheck(this);
}
// In case we set a one-shot check because of a previous failure
......@@ -421,7 +421,7 @@ public class UpdatesActivity extends UpdatesListActivity {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
autoCheckInterval.setSelection(Utils.getUpdateCheckSetting(this));
autoDelete.setChecked(prefs.getBoolean(Constants.PREF_AUTO_DELETE_UPDATES, false));
autoDelete.setChecked(prefs.getBoolean(Constants.PREF_AUTO_DELETE_UPDATES, true));
dataWarning.setChecked(prefs.getBoolean(Constants.PREF_MOBILE_DATA_WARNING, true));
abPerfMode.setChecked(prefs.getBoolean(Constants.PREF_AB_PERF_MODE, false));
......
......@@ -91,7 +91,7 @@ public class UpdatesCheckReceiver extends BroadcastReceiver {
@Override
public void onSuccess(File destination) {
try {
if (json.exists() && Utils.checkForNewUpdates(json, jsonNew)) {
if (json.exists() && Utils.checkForNewUpdates(jsonNew)) {
showNotification(context);
updateRepeatingUpdatesCheck(context);
}
......
......@@ -266,12 +266,7 @@ public class UpdatesListAdapter extends RecyclerView.Adapter<UpdatesListAdapter.
String buildDate = StringGenerator.getDateLocalizedUTC(mActivity,
DateFormat.LONG, update.getTimestamp());
String buildVersion = mActivity.getString(R.string.list_build_version,
update.getDisplayVersion());
if (buildVersion.equals("")) {
buildVersion = mActivity.getString(R.string.list_build_version,
update.getVersion());
}
update.getVersion());
viewHolder.mBuildDate.setText(buildDate);
viewHolder.mBuildVersion.setText(buildVersion);
......@@ -479,7 +474,7 @@ public class UpdatesListAdapter extends RecyclerView.Adapter<UpdatesListAdapter.
String buildDate = StringGenerator.getDateLocalizedUTC(mActivity,
DateFormat.MEDIUM, update.getTimestamp());
String buildInfoText = mActivity.getString(R.string.list_build_version_date,
BuildInfoUtils.getBuildVersion(), buildDate);
update.getVersion(), buildDate);
return new AlertDialog.Builder(mActivity)
.setTitle(R.string.apply_update_dialog_title)
.setMessage(mActivity.getString(resId, buildInfoText,
......
......@@ -408,7 +408,7 @@ public class UpdaterService extends Service {
mNotificationManager.notify(NOTIFICATION_ID, mNotificationBuilder.build());
SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
boolean deleteUpdate = pref.getBoolean(Constants.PREF_AUTO_DELETE_UPDATES, false);
boolean deleteUpdate = pref.getBoolean(Constants.PREF_AUTO_DELETE_UPDATES, true);
if (deleteUpdate) {
mUpdaterController.deleteUpdate(update.getDownloadId());
}
......@@ -492,7 +492,7 @@ public class UpdaterService extends Service {
String buildDate = StringGenerator.getDateLocalizedUTC(this,
DateFormat.MEDIUM, update.getTimestamp());
String buildInfo = getString(R.string.list_build_version_date,
BuildInfoUtils.getBuildVersion(), buildDate);
update.getVersion(), buildDate);
mNotificationStyle.setBigContentTitle(buildInfo);
mNotificationBuilder.setContentTitle(buildInfo);
}
......
......@@ -34,6 +34,7 @@ public final class Constants {
public static final String PREF_AB_PERF_MODE = "ab_perf_mode";
public static final String PREF_MOBILE_DATA_WARNING = "pref_mobile_data_warning";
public static final String PREF_NEEDS_REBOOT_ID = "needs_reboot_id";
public static final String PREF_FORCED_AUTO_DELETE_UPDATES = "force_auto_delete_updates";
public static final String UNCRYPT_FILE_EXT = ".uncrypt";
......
......@@ -260,24 +260,19 @@ public class Utils {
/**
* Compares two json formatted updates list files
*
* @param oldJson old update list
* @param newJson new update list
* @return true if newJson has at least a compatible update not available in oldJson
* @return true if newJson has an update with higher version than the installed system
* @throws IOException
* @throws JSONException
*/
public static boolean checkForNewUpdates(File oldJson, File newJson)
public static boolean checkForNewUpdates(File newJson)
throws IOException, JSONException {
List<UpdateInfo> oldList = parseJson(oldJson, true);
List<UpdateInfo> newList = parseJson(newJson, true);
Set<String> oldIds = new HashSet<>();
for (UpdateInfo update : oldList) {
oldIds.add(update.getDownloadId());
}
// In case of no new updates, the old list should
// have all (if not more) the updates
float currentVersion = Float.parseFloat(BuildInfoUtils.getBuildVersion());
for (UpdateInfo update : newList) {
if (!oldIds.contains(update.getDownloadId())) {
if (Float.parseFloat(update.getVersion()) > currentVersion) {
Log.d(TAG, "New compatiable update available");
return true;
}
}
......@@ -338,11 +333,20 @@ public class Utils {
removeUncryptFiles(downloadPath);
// TODO: Remove after a considerable numbers of OTA
boolean forcedDeleteUpdates = preferences.getBoolean(Constants.PREF_FORCED_AUTO_DELETE_UPDATES, true);
if (forcedDeleteUpdates == true) {
preferences.edit()
.putBoolean(Constants.PREF_AUTO_DELETE_UPDATES, true)
.putBoolean(Constants.PREF_FORCED_AUTO_DELETE_UPDATES, false)
.apply();
}
long buildTimestamp = SystemProperties.getLong(Constants.PROP_BUILD_DATE, 0);
long prevTimestamp = preferences.getLong(Constants.PREF_INSTALL_OLD_TIMESTAMP, 0);
String lastUpdatePath = preferences.getString(Constants.PREF_INSTALL_PACKAGE_PATH, null);
boolean reinstalling = preferences.getBoolean(Constants.PREF_INSTALL_AGAIN, false);
boolean deleteUpdates = preferences.getBoolean(Constants.PREF_AUTO_DELETE_UPDATES, false);
boolean deleteUpdates = preferences.getBoolean(Constants.PREF_AUTO_DELETE_UPDATES, true);
if ((buildTimestamp != prevTimestamp || reinstalling) && deleteUpdates &&
lastUpdatePath != null) {
File lastUpdate = new File(lastUpdatePath);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment