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

Commit 95024927 authored by Mohammed Althaf T's avatar Mohammed Althaf T 😊
Browse files

Updater: Delete local update after installation

parent 9a54761e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -52,7 +52,7 @@ public class UpdateImporter {
    private static final int REQUEST_PICK = 9061;
    private static final String TAG = "UpdateImporter";
    private static final String MIME_ZIP = "application/zip";
    private static final String FILE_NAME = "localUpdate.zip";
    public static final String FILE_NAME = "localUpdate.zip";
    private static final String METADATA_PATH = "META-INF/com/android/metadata";
    private static final String METADATA_TIMESTAMP_KEY = "post-timestamp=";
    private static final String METADATA_ANDROID_SDK_KEY = "post-sdk-level=";
+1 −0
Original line number Diff line number Diff line
@@ -71,6 +71,7 @@ public class UpdatesCheckReceiver extends BroadcastReceiver {
            }

            Utils.cleanupDownloadsDir(context);
            Utils.removeLocalUpdate(context);

            // Reset resume or update check failed on reboot
            editor.putBoolean(Constants.AUTO_UPDATE_CHECK_FAILED, false).apply();
+9 −0
Original line number Diff line number Diff line
@@ -53,6 +53,7 @@ import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.lineageos.updater.R;
import org.lineageos.updater.UpdateImporter;
import org.lineageos.updater.UpdatesDbHelper;
import org.lineageos.updater.controller.UpdaterController;
import org.lineageos.updater.controller.UpdaterService;
@@ -426,6 +427,14 @@ public class Utils {
        }
    }

    public static void removeLocalUpdate(Context context) {
        File downloadPath = getDownloadPath(context);
        File localUpdate = new File(downloadPath, UpdateImporter.FILE_NAME);
        if (localUpdate.exists()) {
            Log.d(TAG, "Deleting local update: " + localUpdate.delete());
        }
    }

    /**
     * Cleanup the download directory, which is assumed to be a privileged location
     * the user can't access and that might have stale files. This can happen if