Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 26f6f861 authored by Sooraj S's avatar Sooraj S 👽
Browse files

New AlertDialog text for version Upgrade

parent e4b54df6
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -112,6 +112,9 @@
    <string name="apply_update_dialog_message">You are about to upgrade to <xliff:g id="update_name">%1$s</xliff:g>.\n\nIf you press <xliff:g id="ok">%2$s</xliff:g>, the device will restart itself in recovery mode to install the update.\n\nNote: This feature requires a compatible Recovery or updates will need to be installed manually.</string>
    <string name="apply_update_dialog_message_ab">You are about to upgrade to <xliff:g id="update_name">%1$s</xliff:g>.\n\nIf you press <xliff:g id="ok">%2$s</xliff:g>, the device will begin installing in the background.\n\nOnce completed, you will be prompted to reboot.</string>

    <string name="apply_upgrade_dialog_title">Upgrade to /e/OS based on Android 10</string>
    <string name="apply_upgrade_dialog_message">You are about to upgrade your phone to a more recent version of /e/OS that is derived from Android 10. It will update your device\'s firmware to a more recent version. This upgrade will give you access to system updates and security patches for at least 3 more years.\n\nConsequently, this update will be longer than usual as it updates more components. Your device may reboot multiple times, and will encrypt your data if they are not already.</string>

    <string name="cancel_installation_dialog_message">Cancel the installation?</string>

    <string name="label_download_url">Download URL</string>
+8 −2
Original line number Diff line number Diff line
@@ -447,11 +447,17 @@ public class UpdatesListAdapter extends RecyclerView.Adapter<UpdatesListAdapter.
                    .setPositiveButton(android.R.string.ok, null);
        }
        UpdateInfo update = mUpdaterController.getUpdate(downloadId);
        int resIdUpgrade;
        int resId;
        try {
            if (Utils.isABUpdate(update.getFile())) {
            if (update.getUpgrade()) {
                resIdUpgrade = R.string.apply_upgrade_dialog_title;
                resId = R.string.apply_upgrade_dialog_message;
            } else if (Utils.isABUpdate(update.getFile())) {
                resIdUpgrade = R.string.apply_update_dialog_title;
                resId = R.string.apply_update_dialog_message_ab;
            } else {
                resIdUpgrade = R.string.apply_update_dialog_title;
                resId = R.string.apply_update_dialog_message;
            }
        } catch (IOException e) {
@@ -464,7 +470,7 @@ public class UpdatesListAdapter extends RecyclerView.Adapter<UpdatesListAdapter.
        String buildInfoText = mActivity.getString(R.string.list_build_version_date,
                BuildInfoUtils.getBuildVersion(), buildDate);
        return new AlertDialog.Builder(mActivity)
                .setTitle(R.string.apply_update_dialog_title)
                .setTitle(resIdUpgrade)
                .setMessage(mActivity.getString(resId, buildInfoText,
                        mActivity.getString(android.R.string.ok)))
                .setPositiveButton(android.R.string.ok,
+22 −15
Original line number Diff line number Diff line
@@ -80,6 +80,25 @@ public class Utils {
        return new File(context.getCacheDir(), "updates.json");
    }

    public static boolean isVersionUpgrade(UpdateBaseInfo update) {
        if (update.getUpgradeSupported()) {
            Log.d(TAG, " is_upgrade_supported :" + update.getUpgradeSupported());
            Log.d(TAG, " Check for newer Android version ");

            if (!update.getReleaseVersion().equals(SystemProperties.get(Constants.PROP_BUILD_RELEASE_VERSION))) {
                Log.d(TAG, update.getName() + " android_version :" + update.getReleaseVersion());
                Version deviceAndroidVersion = new Version(SystemProperties.get(Constants.PROP_BUILD_RELEASE_VERSION));
                Version updateAndroidVersion = new Version(update.getReleaseVersion());
                if (updateAndroidVersion.compareTo(deviceAndroidVersion)==1){
                    Log.d(TAG, " newer Android version is available");
                    return true;
                }
                Log.d(TAG, " Same or old Android version ");
            }
        }
        return false;
    }

    // This should really return an UpdateBaseInfo object, but currently this only
    // used to initialize UpdateInfo objects
    private static UpdateInfo parseJsonUpdate(JSONObject object) throws JSONException {
@@ -94,6 +113,7 @@ public class Utils {
        update.setDisplayVersion(object.getString("display_version"));
        update.setReleaseVersion(object.getString("android_version"));
        update.setUpgradeSupported(object.getBoolean("is_upgrade_supported"));
        update.setUpgrade(isVersionUpgrade(update));
        return update;
    }

@@ -107,21 +127,8 @@ public class Utils {
            Log.d(TAG, update.getName() + " has type " + update.getType());
            return false;
        }
        if (update.getUpgradeSupported()) {
            Log.d(TAG, " is_upgrade_supported :" + update.getUpgradeSupported());
            Log.d(TAG, " Check for newer Android version ");

            if (!update.getReleaseVersion().equals(SystemProperties.get(Constants.PROP_BUILD_RELEASE_VERSION))) {
                Log.d(TAG, update.getName() + " android_version :" + update.getReleaseVersion());
                Version deviceAndroidVersion = new Version(SystemProperties.get(Constants.PROP_BUILD_RELEASE_VERSION));
                Version updateAndroidVersion = new Version(update.getReleaseVersion());
                if (updateAndroidVersion.compareTo(deviceAndroidVersion)==1){
                    Log.d(TAG, " newer Android version is available");
        if(update.getUpgrade())
            return true;
                }
                Log.d(TAG, " Same or old Android version ");
            }
        }

        return true;
    }
+12 −0
Original line number Diff line number Diff line
@@ -26,8 +26,10 @@ public class UpdateBase implements UpdateBaseInfo {
    private String mDisplayVersion;
    private String mReleaseVersion;
    private long mFileSize;
    private boolean mUpgrade;
    private boolean mUpgradeSupported;


    public UpdateBase() {
    }

@@ -42,6 +44,7 @@ public class UpdateBase implements UpdateBaseInfo {
        mReleaseVersion = update.getReleaseVersion();
        mFileSize = update.getFileSize();
        mUpgradeSupported = update.getUpgradeSupported();
        mUpgrade = update.getUpgrade();
    }

    @Override
@@ -134,4 +137,13 @@ public class UpdateBase implements UpdateBaseInfo {
        mUpgradeSupported = upgradeSupported;
    }

    @Override
    public boolean getUpgrade() {
        return mUpgrade;
    }

    public void setUpgrade(boolean upgrade) {
        mUpgrade = upgrade;
    }

}
+3 −0
Original line number Diff line number Diff line
@@ -35,4 +35,7 @@ public interface UpdateBaseInfo {
    long getFileSize();

    boolean getUpgradeSupported();

    boolean getUpgrade();

}