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

Commit 22e3ed22 authored by Sayantan Roychowdhury's avatar Sayantan Roychowdhury
Browse files

feat(updates): Allow App Lounge to update itself (#7982)

parent 54988a4c
Loading
Loading
Loading
Loading
+95 −0
Original line number Diff line number Diff line
@@ -2,16 +2,27 @@ image: registry.gitlab.e.foundation/e/os/docker-android-apps-cicd:master

variables:
  SENTRY_DSN: $SENTRY_DSN
  PROJECT_ID: "355" # under Settings -> General
  APK_PATH: "apks"
  UNSIGNED_APK: "AppLounge-release.apk"
  DEV_APK: "AppLounge-release-dev.apk"
  STABLE_APK: "AppLounge-release-stable.apk"

stages:
  - debug
  - release
  - publish
  - gitlab_release

before_script:
  - export GRADLE_USER_HOME=$(pwd)/.gradle
  - chmod +x ./gradlew

cache:
  key: ${CI_PROJECT_ID}
  paths:
    - .gradle/

# Debug build related jobs
buildDebug:
  stage: debug
@@ -173,6 +184,7 @@ pushToPrebuilt:
    - git push
    # Sometimes a single push doesn't do all the job, so we have to push twice
    - git push
  allow_failure: true

publish-contracts:
  stage: publish
@@ -186,3 +198,86 @@ publish-contracts:
    - ./gradlew :parental-control-data:build
    - ./gradlew :parental-control-data:publish
  allow_failure: true

init-submodules:
  stage: gitlab_release
  needs: []
  rules:
    - if: '$CI_COMMIT_TAG && $CI_COMMIT_REF_PROTECTED == "true"'
      when: on_success
  script:
    - |
      git submodule add --force \
      https://gitlab.e.foundation/e/os/system-apps-update-info.git systemAppsUpdateInfo
  artifacts:
    paths:
      - systemAppsUpdateInfo/

generate-apks:
  stage: gitlab_release
  rules:
    - if: '$CI_COMMIT_TAG && $CI_COMMIT_REF_PROTECTED == "true"'
      when: on_success
  needs:
    - init-submodules
    - buildRelease
    - buildReleaseDev
    - buildReleaseStable
  dependencies:
    - init-submodules
    - buildRelease
    - buildReleaseDev
    - buildReleaseStable
  script:
    - mkdir -p $APK_PATH
    - unsignedApk=$(ls app/build/outputs/apk/release/*.apk | grep "release")
    - devApk=$(ls app/build/outputs/apk/releaseDev/*.apk | grep "releaseDev")
    - stableApk=$(ls app/build/outputs/apk/releaseStable/*.apk | grep "releaseStable")
    - cp "$unsignedApk" "$APK_PATH/$UNSIGNED_APK"
    - cp "$devApk" "$APK_PATH/$DEV_APK"
    - cp "$stableApk" "$APK_PATH/$STABLE_APK"
  artifacts:
    paths:
      - $APK_PATH/$UNSIGNED_APK
      - $APK_PATH/$DEV_APK
      - $APK_PATH/$STABLE_APK

create-json-files:
  stage: gitlab_release
  dependencies:
    - init-submodules
    - generate-apks
  needs:
    - init-submodules
    - generate-apks
  rules:
    - if: '$CI_COMMIT_TAG && $CI_COMMIT_REF_PROTECTED == "true"'
      when: manual
  before_script:
    - apt update && apt install jq aapt -y
  script:
    - |
      ./systemAppsUpdateInfo/scripts/create-json-files.sh \
      "$APK_PATH" "$UNSIGNED_APK" "$DEV_APK" "$STABLE_APK"
  artifacts:
    paths:
      - dev.json
      - stable.json

create-release:
  stage: gitlab_release
  dependencies:
    - init-submodules
  needs:
    - init-submodules
    - create-json-files
    - generate-apks
  rules:
    - if: '$CI_COMMIT_TAG && $CI_COMMIT_REF_PROTECTED == "true"'
      when: on_success
  before_script:
    - apt update && apt install jq -y
  script:
    - |
      ./systemAppsUpdateInfo/scripts/create-release.sh \
      "$APK_PATH" "$UNSIGNED_APK" "$DEV_APK" "$STABLE_APK"
 No newline at end of file
+1 −0
Original line number Diff line number Diff line
@@ -101,6 +101,7 @@
            android:exported="false">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
                <action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
            </intent-filter>
        </receiver>
        
+18 −1
Original line number Diff line number Diff line
@@ -52,7 +52,20 @@ class SystemAppsUpdatesRepository @Inject constructor(
            if (getUpdatableSystemApps().isNotEmpty() && !forceRefresh) {
                return@handleNetworkResult
            }
            val response = updatableSystemAppsApi.getUpdatableSystemApps()

            val systemName = getFullSystemName()
            val endPoint = if (
                systemName.isBlank() ||
                systemName.contains("beta") ||
                systemName.contains("rc")
            ) {
                UpdatableSystemAppsApi.EndPoint.ENDPOINT_TEST
            } else {
                UpdatableSystemAppsApi.EndPoint.ENDPOINT_RELEASE
            }

            val response = updatableSystemAppsApi.getUpdatableSystemApps(endPoint)

            if (response.isSuccessful && !response.body().isNullOrEmpty()) {
                systemAppProjectList.clear()
                response.body()?.let { systemAppProjectList.addAll(it) }
@@ -103,6 +116,10 @@ class SystemAppsUpdatesRepository @Inject constructor(
        }
    }

    private fun getFullSystemName(): String {
        return SystemInfoProvider.getSystemProperty(SystemInfoProvider.KEY_LINEAGE_VERSION) ?: ""
    }

    private fun getSdkLevel(): Int {
        return Build.VERSION.SDK_INT
    }
+14 −2
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ package foundation.e.apps.data.gitlab
import foundation.e.apps.data.gitlab.models.SystemAppProject
import retrofit2.Response
import retrofit2.http.GET
import retrofit2.http.Path

interface UpdatableSystemAppsApi {

@@ -28,7 +29,18 @@ interface UpdatableSystemAppsApi {
            "https://gitlab.e.foundation/e/os/system-apps-update-info/-/raw/main/"
    }

    @GET("updatable_system_apps.json?inline=false")
    suspend fun getUpdatableSystemApps(): Response<List<SystemAppProject>>
    enum class EndPoint(private val value: String) {
        ENDPOINT_RELEASE("updatable_system_apps.json"),
        ENDPOINT_TEST("updatable_system_apps_test.json"),
        ;
        override fun toString(): String {
            return value
        }
    }

    @GET("{endPoint}?inline=false")
    suspend fun getUpdatableSystemApps(
        @Path("endPoint") endPoint: EndPoint = EndPoint.ENDPOINT_RELEASE
    ): Response<List<SystemAppProject>>

}
+7 −1
Original line number Diff line number Diff line
@@ -99,8 +99,14 @@ class AppManagerImpl @Inject constructor(
            appInstallRepository.deleteDownload(appInstall)
        } else if (status == Status.INSTALLING) {
            appInstall.downloadIdMap.all { true }
            appInstall.status = status
            val isSelfUpdate = appInstall.packageName == context.packageName
            if (isSelfUpdate) {
                appInstallRepository.deleteDownload(appInstall)
            } else {
                appInstall.status = status
                appInstallRepository.updateDownload(appInstall)
            }
            installApp(appInstall)
        }
    }
Loading