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

Commit 0342bb31 authored by Michael W's avatar Michael W Committed by Nolen Johnson
Browse files

Updater: Fix warnings

* Unused imports
* Unused code
* Unused resources
* Set.isEmpty() instead of .size() == 0
* try-with-resources

Change-Id: Ia9351986c62e8e5f8d4615f6146827b891f55f9e
parent 33d63d62
Loading
Loading
Loading
Loading
+1 −5
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017-2022 The LineageOS Project
 * Copyright (C) 2017-2025 The LineageOS Project
 * Copyright (C) 2020-2022 SHIFT GmbH
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
@@ -23,13 +23,10 @@ import android.net.Uri;
import android.os.ParcelFileDescriptor;
import android.util.Log;

import org.json.JSONException;
import org.lineageos.updater.controller.UpdaterController;
import org.lineageos.updater.controller.UpdaterService;
import org.lineageos.updater.misc.StringGenerator;
import org.lineageos.updater.misc.Utils;
import org.lineageos.updater.model.Update;
import org.lineageos.updater.model.UpdateInfo;
import org.lineageos.updater.model.UpdateStatus;

import java.io.File;
@@ -41,7 +38,6 @@ import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.text.DateFormat;
import java.util.Enumeration;
import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;

+2 −7
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017-2024 The LineageOS Project
 * Copyright (C) 2017-2025 The LineageOS Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
@@ -15,12 +15,10 @@
 */
package org.lineageos.updater;

import android.app.Activity;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.net.Uri;
import android.os.BatteryManager;
import android.os.PowerManager;
import android.text.SpannableString;
@@ -40,8 +38,6 @@ import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;

import androidx.activity.result.ActivityResultLauncher;
import androidx.activity.result.contract.ActivityResultContracts;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.view.ContextThemeWrapper;
@@ -55,7 +51,6 @@ import com.google.android.material.snackbar.Snackbar;

import org.lineageos.updater.controller.UpdaterController;
import org.lineageos.updater.controller.UpdaterService;
import org.lineageos.updater.misc.BuildInfoUtils;
import org.lineageos.updater.misc.Constants;
import org.lineageos.updater.misc.StringGenerator;
import org.lineageos.updater.misc.Utils;
@@ -607,7 +602,7 @@ public class UpdatesListAdapter extends RecyclerView.Adapter<UpdatesListAdapter.
    private boolean isBatteryLevelOk() {
        Intent intent = mActivity.registerReceiver(null,
                new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
        if (!intent.getBooleanExtra(BatteryManager.EXTRA_PRESENT, false)) {
        if (intent == null || !intent.getBooleanExtra(BatteryManager.EXTRA_PRESENT, false)) {
            return true;
        }
        int percent = Math.round(100.f * intent.getIntExtra(BatteryManager.EXTRA_LEVEL, 100) /
+0 −1
Original line number Diff line number Diff line
@@ -256,7 +256,6 @@ class ABUpdateInstaller {
    }

    private void installationDone(boolean needsReboot) {
        SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mContext);
        String id = needsReboot ? mDownloadId : null;
        PreferenceManager.getDefaultSharedPreferences(mContext).edit()
                .putString(Constants.PREF_NEEDS_REBOOT_ID, id)
+2 −2
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017-2022 The LineageOS Project
 * Copyright (C) 2017-2025 The LineageOS Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
@@ -522,7 +522,7 @@ public class UpdaterController {
    }

    public boolean isVerifyingUpdate() {
        return mVerifyingUpdates.size() > 0;
        return !mVerifyingUpdates.isEmpty();
    }

    public boolean isVerifyingUpdate(String downloadId) {
+2 −4
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017-2022 The LineageOS Project
 * Copyright (C) 2017-2025 The LineageOS Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
@@ -38,7 +38,6 @@ import androidx.preference.PreferenceManager;
import org.lineageos.updater.R;
import org.lineageos.updater.UpdaterReceiver;
import org.lineageos.updater.UpdatesActivity;
import org.lineageos.updater.misc.BuildInfoUtils;
import org.lineageos.updater.misc.Constants;
import org.lineageos.updater.misc.StringGenerator;
import org.lineageos.updater.misc.Utils;
@@ -46,7 +45,6 @@ import org.lineageos.updater.model.Update;
import org.lineageos.updater.model.UpdateInfo;
import org.lineageos.updater.model.UpdateStatus;

import java.io.File;
import java.io.IOException;
import java.text.DateFormat;
import java.text.NumberFormat;
@@ -127,7 +125,7 @@ public class UpdaterService extends Service {
                } else if (UpdaterController.ACTION_UPDATE_REMOVED.equals(intent.getAction())) {
                    final boolean isLocalUpdate = Update.LOCAL_ID.equals(downloadId);
                    Bundle extras = mNotificationBuilder.getExtras();
                    if (extras != null && !isLocalUpdate && downloadId.equals(
                    if (!isLocalUpdate && downloadId != null && downloadId.equals(
                            extras.getString(UpdaterController.EXTRA_DOWNLOAD_ID))) {
                        mNotificationBuilder.setExtras(null);
                        UpdateInfo update = mUpdaterController.getUpdate(downloadId);
Loading