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

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

Updater: Remove update before loading list

parent 9ae401db
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -121,6 +121,10 @@ public class UpdatesActivity extends UpdatesListActivity implements UpdateImport
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_updates);

        if (UpdaterService.isDeviceRebooted()) {
            Utils.removeInstalledUpdate(this);
        }

        mUpdateImporter = new UpdateImporter(this, this);

        UiModeManager uiModeManager = getSystemService(UiModeManager.class);
+7 −0
Original line number Diff line number Diff line
@@ -99,6 +99,8 @@ public class UpdaterService extends Service {
    private static ConnectivityManager.NetworkCallback mConnectionStateMonitor;
    private static ConnectivityManager mConnectivityManager;

    private static boolean mDeviceRebooted = true;

    @Override
    public void onCreate() {
        super.onCreate();
@@ -267,6 +269,10 @@ public class UpdaterService extends Service {
        return mUpdaterController;
    }

    public static boolean isDeviceRebooted() {
        return mDeviceRebooted;
    }

    private void tryStopSelf() {
        if (isNetworkCallBackActive || areNotificationsActive()) return;
        if (!mHasClients && !mUpdaterController.hasActiveDownloads() &&
@@ -287,6 +293,7 @@ public class UpdaterService extends Service {
        SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
        SharedPreferences.Editor editor = pref.edit();
        mNotificationBuilder.setPriority(NotificationCompat.PRIORITY_DEFAULT);
        mDeviceRebooted = false;
        switch (update.getStatus()) {
            case DELETED: {
                notifySystemUpdaterService(STATUS_WAITING_DOWNLOAD, update);
+5 −3
Original line number Diff line number Diff line
@@ -488,9 +488,11 @@ public class Utils {
    public static void removeInstalledUpdate(Context context) {
        SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context);
        String downloadId = pref.getString(Constants.PREF_NEEDS_DELETE_ID, null);
        if (downloadId != null) {
            UpdaterController controller = UpdaterController.getInstance(context);
        if (controller != null && downloadId != null) {
            if (controller != null) {
                controller.deleteUpdate(downloadId);
            }
            pref.edit().remove(Constants.PREF_NEEDS_DELETE_ID).apply();
        }
    }