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

Commit 639fbd46 authored by Sayantan Roychowdhury's avatar Sayantan Roychowdhury
Browse files

Issue 1312: fix lint warnings

parent f763809b
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    <uses-permission android:name="android.permission.UPDATE_PACKAGES_WITHOUT_USER_ACTION" />
    <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
    <uses-permission android:name="android.permission.WRITE_SETTINGS"
        tools:ignore="ProtectedPermissions" />
    <uses-permission
@@ -67,13 +68,16 @@
            </intent-filter>
        </receiver>

        <receiver android:name=".install.updates.UpdatesBroadcastReceiver">
        <receiver android:name=".install.updates.UpdatesBroadcastReceiver"
            android:exported="false">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
            </intent-filter>
        </receiver>

        <!-- TODO: ExportedReceiver, suppressing because changes are needed in other apps -->
        <receiver android:name=".install.receiver.PWAPlayerStatusReceiver"
            tools:ignore="ExportedReceiver"
            android:exported="true">
            <intent-filter>
                <action android:name="foundation.e.pwaplayer.PWA_ADDED" />
@@ -86,7 +90,8 @@
            </intent-filter>
        </receiver>

        <receiver android:name=".ui.setup.signin.LocaleChangedBroadcastReceiver">
        <receiver android:name=".ui.setup.signin.LocaleChangedBroadcastReceiver"
            android:exported="false">
            <intent-filter>
                <action android:name="android.intent.action.LOCALE_CHANGED"/>
            </intent-filter>
@@ -100,8 +105,10 @@

        <service android:name=".install.pkg.PackageInstallerService" />

        <!-- TODO: ExportedService, suppressing because changes are needed in other apps -->
        <service
            android:name=".install.splitinstall.SplitInstallService"
            tools:ignore="ExportedService"
            android:exported="true" />
    </application>

+3 −3
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ package foundation.e.apps.data
import android.app.DownloadManager
import android.content.Context
import android.net.Uri
import android.os.Environment
import dagger.hilt.android.qualifiers.ApplicationContext
import foundation.e.apps.OpenForTesting
import foundation.e.apps.R
@@ -47,9 +48,8 @@ class DownloadManager @Inject constructor(
) {
    private val downloadsMaps = HashMap<Long, Boolean>()

    companion object {
        const val EXTERNAL_STORAGE_TEMP_CACHE_DIR = "/sdcard/Download/AppLounge/SplitInstallApks"
    }
    private val SDCARD_PATH = Environment.getExternalStorageDirectory().absolutePath
    val EXTERNAL_STORAGE_TEMP_CACHE_DIR = "$SDCARD_PATH/Download/AppLounge/SplitInstallApks"

    fun downloadFileInCache(
        url: String,
+0 −78
Original line number Diff line number Diff line
package foundation.e.apps.data

import foundation.e.apps.data.enums.ResultStatus

/**
 * Currently defunct, not being used anywhere.
 * Prototype to merge API request and also get rid of Pair, Triple for timeout related cases.
 */
open class JobResult<T> private constructor(val status: ResultStatus) {

    /*
     * Classes for returning multiple data from a function along with a status
     * in the form of ResultStatus.
     * Use the static overloaded create methods (in companion object) to for easy creation.
     *
     * If needed to just pass a single data element with status for API requests,
     * see the static methods success(), error(), loading() (in companion object).
     */
    class of1<A> (val data1: A, status: ResultStatus) : JobResult<A>(status)
    class of2<A, B> (val data1: A, val data2: B, status: ResultStatus) : JobResult<A>(status)
    class of3<A, B, C> (val data1: A, val data2: B, val data3: C, status: ResultStatus) : JobResult<A>(status)

    var message = ""

    /*
     * This is the primary data, mainly for API requests which might send null data.
     * Other data (type B, C ...) are secondary/optional data.
     *
     * For non-null return type, directly use of1, of2, of3 ... classes
     * and directly access data1, data2, data3 ...
     */
    val data: T? get() = when (this) {
        is of1 -> this.data1
        is of2<T, *> -> this.data1
        is of3<T, *, *> -> this.data1
        else -> null
    }

    fun isSuccess(): Boolean {
        return status == ResultStatus.OK
    }

    companion object {
        fun <A> create(data1: A, status: ResultStatus, message: String? = null): of1<A> {
            return of1(data1, status).apply {
                message?.let { this.message = message }
            }
        }
        fun <A, B> create(data1: A, data2: B, status: ResultStatus, message: String? = null): of2<A, B> {
            return of2(data1, data2, status).apply {
                message?.let { this.message = message }
            }
        }
        fun <A, B, C> create(data1: A, data2: B, data3: C, status: ResultStatus, message: String? = null): of3<A, B, C> {
            return of3(data1, data2, data3, status).apply {
                message?.let { this.message = message }
            }
        }

        /*
         * Methods for API
         */
        fun <T> success(data: T): JobResult<T> {
            return of1(data, ResultStatus.OK)
        }
        fun <T> error(message: String, data: T? = null): JobResult<T> {
            val result = if (data == null) JobResult(ResultStatus.UNKNOWN)
            else of1<T>(data, ResultStatus.UNKNOWN)
            return result.apply {
                this.message = message
            }
        }
        /*fun <T> loading(data: T?): JobResult<T> {
            return if (data == null) JobResult(ResultStatus.LOADING)
            else JobResult.of1(data, ResultStatus.LOADING)
        }*/
    }
}
+2 −2
Original line number Diff line number Diff line
@@ -19,7 +19,6 @@
package foundation.e.apps.data.cleanapk

import android.os.Build
import android.util.Log
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory
import com.google.gson.Gson
@@ -46,6 +45,7 @@ import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
import retrofit2.converter.jackson.JacksonConverterFactory
import retrofit2.converter.moshi.MoshiConverterFactory
import timber.log.Timber
import java.net.ConnectException
import java.util.Locale
import javax.inject.Named
@@ -193,7 +193,7 @@ object RetrofitModule {
        e: Exception,
        chain: Interceptor.Chain
    ): Response {
        Log.e("Retrofit", "buildErrorResponse: ${e.localizedMessage}")
        Timber.e("buildErrorResponse: ${e.localizedMessage}")
        return Response.Builder()
            .code(999)
            .message(e.localizedMessage ?: "Unknown error")
+0 −3
Original line number Diff line number Diff line
@@ -21,9 +21,7 @@ package foundation.e.apps.install.pkg
import android.app.Service
import android.content.Intent
import android.content.pm.PackageInstaller
import android.os.Build
import android.os.IBinder
import androidx.annotation.RequiresApi
import dagger.hilt.android.AndroidEntryPoint
import foundation.e.apps.data.enums.Status
import foundation.e.apps.data.faultyApps.FaultyAppRepository
@@ -55,7 +53,6 @@ class InstallerService : Service() {
        const val INSTALL_FAILED_UPDATE_INCOMPATIBLE = "INSTALL_FAILED_UPDATE_INCOMPATIBLE"
    }

    @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
    override fun onStartCommand(intent: Intent, flags: Int, startId: Int): Int {
        val status = intent.getIntExtra(PackageInstaller.EXTRA_STATUS, -69)
        var packageName = intent.getStringExtra(PackageInstaller.EXTRA_PACKAGE_NAME)
Loading