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

Commit 6584a103 authored by Nishant D's avatar Nishant D
Browse files

Merge branch 'main' into 1347-improve-local-cache

parents a11ec944 7b8f34c5
Loading
Loading
Loading
Loading
Loading
+3 −4
Original line number Diff line number Diff line
@@ -11,7 +11,7 @@ plugins {

def versionMajor = 2
def versionMinor = 5
def versionPatch = 2
def versionPatch = 5

def getGitHash = { ->
    def stdOut = new ByteArrayOutputStream()
@@ -150,9 +150,8 @@ dependencies {
    // TODO: Add splitinstall-lib to a repo https://gitlab.e.foundation/e/os/backlog/-/issues/628
    api files('libs/splitinstall-lib.jar')

    implementation 'foundation.e.lib:telemetry:0.0.8-alpha'

    implementation 'foundation.e:gplayapi:3.0.1'
    implementation 'foundation.e.lib:telemetry:0.0.9-alpha'
    implementation 'foundation.e:gplayapi:3.0.1-2'
    implementation 'androidx.core:core-ktx:1.9.0'
    implementation 'androidx.appcompat:appcompat:1.6.1'
    implementation 'androidx.fragment:fragment-ktx:1.5.6'
+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>

+1 −1
Original line number Diff line number Diff line
@@ -78,7 +78,7 @@ class AppLoungeApplication : Application(), Configuration.Provider {
            Telemetry.init(BuildConfig.SENTRY_DSN, this)
            plant(object : Timber.Tree() {
                override fun log(priority: Int, tag: String?, message: String, t: Throwable?) {
                    if (priority < Log.WARN) {
                    if (priority <= Log.WARN) {
                        return
                    }
                    Log.println(priority, tag, message)
+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)
        }*/
    }
}
Loading