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

Commit eec990a1 authored by Sooraj S's avatar Sooraj S 👽
Browse files

New AlertDialog text for version Upgrade

parent cef2c0e0
Loading
Loading
Loading
Loading
+8 −12
Original line number Diff line number Diff line
@@ -21,11 +21,11 @@ if ! adb root; then
    exit 1
fi

# zip_path_device=$updates_dir/`basename "$zip_path"`
# if adb shell test -f "$zip_path_device"; then
#     echo "$zip_path_device exists already"
#     exit 1
# fi
zip_path_device=$updates_dir/`basename "$zip_path"`
if adb shell test -f "$zip_path_device"; then
    echo "$zip_path_device exists already"
    exit 1
fi

if [ -n "$2" ]; then
    status=1
@@ -44,9 +44,9 @@ size=`stat -c "%s" "$zip_path"`
display_version=
android_version='10'

# adb push "$zip_path" "$zip_path_device"
# adb shell chgrp cache "$zip_path_device"
# adb shell chmod 664 "$zip_path_device"
adb push "$zip_path" "$zip_path_device"
adb shell chgrp cache "$zip_path_device"
adb shell chmod 664 "$zip_path_device"

# Kill the app before updating the database
adb shell "killall org.lineageos.updater 2>/dev/null"
@@ -54,10 +54,6 @@ adb shell "sqlite3 /data/data/org.lineageos.updater/databases/updates.db" \
    "\"INSERT INTO updates (status, path, download_id, timestamp, type, version, size)" \
    "  VALUES ($status, '$zip_path_device', '$id', $timestamp, '$type', '$version', $size)\""

# adb shell "sqlite3 /data/data/org.lineageos.updater/databases/updates.db" \
#     "\"INSERT INTO updates (status, path, download_id, timestamp, type, version, android_version, size)" \
#     "  VALUES ($status, '$zip_path_device', '$id', $timestamp, '$type', '$version', '$android_version', $size)\""

# adb shell "sqlite3 /data/data/org.lineageos.updater/databases/updates.db" \
#     "\"INSERT INTO updates (status, path, download_id, timestamp, type, version, display_version, android_version, size)" \
#     "  VALUES ($status, '$zip_path_device', '$id', $timestamp, '$type', '$version', '$display_version', '$android_version', $size)\""
+4 −3
Original line number Diff line number Diff line
@@ -32,9 +32,6 @@
          {type} - Build type
          {incr} - Incremental version
    -->
    <!-- Hardcoded url for test  -->
    <!-- <string name="updater_server_url" translatable="false">https://test.ota.ecloud.global/api/v1/star2lte/test/bb6c8035df</string> -->

    <string name="updater_server_url" translatable="false">https://test.ota.ecloud.global/api/v1/{device}/{type}/{incr}</string>

    <string name="verification_failed_notification">Verification failed</string>
@@ -115,6 +112,10 @@
    <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="apply_upgrade_dialog_message_ab">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,
+41 −17
Original line number Diff line number Diff line
@@ -40,8 +40,6 @@ import org.lineageos.updater.controller.UpdaterService;
import org.lineageos.updater.model.UpdateBaseInfo;
import org.lineageos.updater.model.Update;
import org.lineageos.updater.model.UpdateInfo;
import org.lineageos.updater.UpdatesDbHelper;


import java.io.BufferedReader;
import java.io.File;
@@ -55,8 +53,6 @@ import java.util.Locale;
import java.util.Set;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import java.util.regex.Pattern;


public class Utils {

@@ -84,6 +80,23 @@ public class Utils {
        return new File(context.getCacheDir(), "updates.json");
    }

    public static boolean isVersionUpgrade(UpdateBaseInfo update) {
        if (!update.getReleaseVersion().equals(SystemProperties.get(Constants.PROP_BUILD_RELEASE_VERSION))) {
            // Update upgrade = new Update();
            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");
                // upgrade.setUpgrade(true);
                return true;
            }
            Log.d(TAG, " Same or old Android version ");
            // upgrade.setUpgrade(false);
        }
            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 {
@@ -98,11 +111,15 @@ public class Utils {
        update.setDisplayVersion(object.getString("display_version"));
        update.setReleaseVersion(object.getString("android_version"));
        update.setUpgradeSupported(object.getBoolean("is_upgrade_supported"));
        if(isVersionUpgrade(update))
            update.setUpgrade(true);
        else
            update.setUpgrade(false);

        return update;
    }
    
    public static boolean isCompatible(UpdateBaseInfo update) {

        if (!SystemProperties.getBoolean(Constants.PROP_UPDATER_ALLOW_DOWNGRADING, false) &&
                update.getTimestamp() <= SystemProperties.getLong(Constants.PROP_BUILD_DATE, 0)) {
            Log.d(TAG, update.getName() + " is older than/equal to the current build");
@@ -116,22 +133,29 @@ public class Utils {
            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());
            // if (!update.getReleaseVersion().equals(SystemProperties.get(Constants.PROP_BUILD_RELEASE_VERSION))) {
            //     // Update upgrade = new Update();
            //     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");
                Version a = new Version(SystemProperties.get(Constants.PROP_BUILD_RELEASE_VERSION));
                Version b = new Version(update.getReleaseVersion());
                if (b.compareTo(a)==1){
                    Log.d(TAG, " newer Android version is available");
            //         // upgrade.setUpgrade(true);
            //         return true;
            //     }
            //     Log.d(TAG, " Same or old Android version ");
            //     // upgrade.setUpgrade(false);
            // }

            if(isVersionUpgrade(update))
                return true;
        }
                Log.d(TAG, " Same or old Android version ");
            }
        }

        return true;
    }



    public static boolean canInstall(UpdateBaseInfo update) {
        return (SystemProperties.getBoolean(Constants.PROP_UPDATER_ALLOW_DOWNGRADING, false) ||
                update.getTimestamp() > SystemProperties.getLong(Constants.PROP_BUILD_DATE, 0));
+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;
    }

}
Loading