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

Commit 34773e90 authored by Mohammed Althaf T's avatar Mohammed Althaf T 😊
Browse files

apps: Define foregroundServiceType

- Required since android 14
parent 2db6c898
Loading
Loading
Loading
Loading
Loading
+29 −4
Original line number Diff line number Diff line
@@ -28,7 +28,9 @@
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.GET_TASKS" />
    <uses-permission android:name="foundation.e.pwaplayer.provider.READ_WRITE" />

    <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE" />
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC"/>
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
@@ -84,7 +86,14 @@
            </intent-filter>
            <nav-graph android:value="@navigation/navigation_resource" />
        </activity>
        <service android:name=".install.pkg.InstallerService" />

        <service
            android:name=".install.pkg.InstallerService"
            android:foregroundServiceType="specialUse">
            <property
                android:name="android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE"
                android:value="updater"/>
        </service>

        <receiver
            android:name="foundation.e.apps.install.download.DownloadManagerBR"
@@ -157,13 +166,29 @@
            android:exported="true"
            android:readPermission="${applicationId}.permission.PROVIDER_READ" />

        <service android:name=".install.pkg.PackageInstallerService" />
        <service
            android:name=".install.pkg.PackageInstallerService"
            android:foregroundServiceType="specialUse">
            <property
                android:name="android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE"
                android:value="updater"/>
        </service>

        <!-- TODO: ExportedService, suppressing because changes are needed in other apps -->
        <service
            android:name=".install.splitinstall.SplitInstallService"
            tools:ignore="ExportedService"
            android:exported="true" />
            android:exported="true"
            android:foregroundServiceType="specialUse">
            <property
                android:name="android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE"
                android:value="updater"/>
        </service>

        <service
            android:name="androidx.work.impl.foreground.SystemForegroundService"
            android:foregroundServiceType="dataSync"
            tools:node="merge" />

        <receiver
            android:name=".install.splitinstall.SplitInstallBinder$IgnoreReceiver"
+13 −1
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ package foundation.e.apps.install.workmanager
import android.app.NotificationChannel
import android.app.NotificationManager
import android.content.Context
import android.content.pm.ServiceInfo
import android.os.Build
import androidx.core.app.NotificationCompat
import androidx.hilt.work.HiltWorker
@@ -100,6 +101,17 @@ class InstallAppWorker @AssistedInject constructor(
            .addAction(android.R.drawable.ic_delete, cancel, intent)
            .build()

        return ForegroundInfo(atomicInteger.getAndIncrement(), notification)
        // Set the foreground service type for Android 14+
        return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
            ForegroundInfo(
                atomicInteger.getAndIncrement(),
                notification,
                ServiceInfo.FOREGROUND_SERVICE_TYPE_SPECIAL_USE // Specify a valid service type
            )
        } else {
            ForegroundInfo(
                atomicInteger.getAndIncrement(),
                notification)
        }
    }
}