Skip to content

Commit 1e61099

Browse files
committed
updater services
1 parent ce1be41 commit 1e61099

File tree

18 files changed

+620
-145
lines changed

18 files changed

+620
-145
lines changed

app/src/main/AndroidManifest.xml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,20 @@
128128
android:exported="false"
129129
android:foregroundServiceType="dataSync" />
130130

131+
<service
132+
android:name=".service.RepositoryService"
133+
android:exported="false"
134+
android:foregroundServiceType="dataSync" />
135+
136+
<service
137+
android:name=".service.ModuleService"
138+
android:exported="false"
139+
android:foregroundServiceType="dataSync" />
140+
131141
<service
132142
android:name=".service.ProviderService"
133143
android:exported="false"
134-
android:foregroundServiceType="specialUse" />
144+
android:foregroundServiceType="specialUse" />
135145

136146
<service
137147
android:name=".service.LogcatService"
@@ -162,8 +172,7 @@
162172
android:grantUriPermissions="true">
163173
<meta-data
164174
android:name="android.support.FILE_PROVIDER_PATHS"
165-
android:resource="@xml/provider_paths">
166-
</meta-data>
175+
android:resource="@xml/provider_paths" />
167176
</provider>
168177

169178
<provider

app/src/main/kotlin/com/dergoogler/mmrl/app/utils/NotificationUtils.kt

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,35 @@ import com.dergoogler.mmrl.R
88

99
object NotificationUtils {
1010
const val CHANNEL_ID_DOWNLOAD = "DOWNLOAD"
11+
const val CHANNEL_ID_PROVIDER = "PROVIDER"
12+
const val CHANNEL_ID_REPOSITORY = "REPOSITORY"
13+
const val CHANNEL_ID_MODULE = "MODULE"
1114
const val NOTIFICATION_ID_DOWNLOAD = 1024
15+
const val NOTIFICATION_ID_PROVIDER = 2024
16+
const val NOTIFICATION_ID_REPOSITORY = 3024
17+
const val NOTIFICATION_ID_MODULE = 4024
1218

1319
fun init(context: Context) {
1420
val channels = listOf(
15-
NotificationChannel(CHANNEL_ID_DOWNLOAD,
21+
NotificationChannel(
22+
CHANNEL_ID_DOWNLOAD,
1623
context.getString(R.string.notification_name_download),
1724
NotificationManager.IMPORTANCE_HIGH
25+
),
26+
NotificationChannel(
27+
CHANNEL_ID_REPOSITORY,
28+
context.getString(R.string.notification_name_repository),
29+
NotificationManager.IMPORTANCE_NONE
30+
),
31+
NotificationChannel(
32+
CHANNEL_ID_PROVIDER,
33+
context.getString(R.string.notification_name_provider),
34+
NotificationManager.IMPORTANCE_NONE
35+
),
36+
NotificationChannel(
37+
CHANNEL_ID_MODULE,
38+
context.getString(R.string.notification_name_module),
39+
NotificationManager.IMPORTANCE_HIGH
1840
)
1941
)
2042

app/src/main/kotlin/com/dergoogler/mmrl/datastore/UserPreferencesDataSource.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ class UserPreferencesDataSource @Inject constructor(
9797
}
9898
}
9999

100-
suspend fun setAutoUpdateReposInterval(value: Int) = withContext(Dispatchers.IO) {
100+
suspend fun setAutoUpdateReposInterval(value: Long) = withContext(Dispatchers.IO) {
101101
userPreferences.updateData {
102102
it.copy(
103103
autoUpdateReposInterval = value
@@ -113,7 +113,7 @@ class UserPreferencesDataSource @Inject constructor(
113113
}
114114
}
115115

116-
suspend fun setCheckModuleUpdatesInterval(value: Int) = withContext(Dispatchers.IO) {
116+
suspend fun setCheckModuleUpdatesInterval(value: Long) = withContext(Dispatchers.IO) {
117117
userPreferences.updateData {
118118
it.copy(
119119
checkModuleUpdatesInterval = value
Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
package com.dergoogler.mmrl.datastore.model
22

3+
import kotlinx.serialization.ExperimentalSerializationApi
34
import kotlinx.serialization.Serializable
5+
import kotlinx.serialization.protobuf.ProtoNumber
46

57
@Serializable
6-
data class ModulesMenu(
7-
val option: Option = Option.Name,
8-
val descending: Boolean = false,
9-
val pinEnabled: Boolean = true,
10-
val pinAction: Boolean = false,
11-
val pinWebUI: Boolean = false,
12-
val showUpdatedTime: Boolean = true
8+
data class ModulesMenu @OptIn(ExperimentalSerializationApi::class) constructor(
9+
@ProtoNumber(1) val option: Option = Option.Name,
10+
@ProtoNumber(2) val descending: Boolean = false,
11+
@ProtoNumber(3) val pinEnabled: Boolean = true,
12+
@ProtoNumber(4) val pinAction: Boolean = false,
13+
@ProtoNumber(5) val pinWebUI: Boolean = false,
14+
@ProtoNumber(6) val showUpdatedTime: Boolean = true
1315
)
Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
package com.dergoogler.mmrl.datastore.model
22

3+
import kotlinx.serialization.ExperimentalSerializationApi
34
import kotlinx.serialization.Serializable
5+
import kotlinx.serialization.protobuf.ProtoNumber
46

57
@Serializable
6-
data class RepositoriesMenu(
7-
val option: Option = Option.Name,
8-
val descending: Boolean = false,
9-
val showModulesCount: Boolean = true,
10-
val showUpdatedTime: Boolean = true,
11-
val showCover: Boolean = true,
8+
data class RepositoriesMenu @OptIn(ExperimentalSerializationApi::class) constructor(
9+
@ProtoNumber(1) val option: Option = Option.Name,
10+
@ProtoNumber(2) val descending: Boolean = false,
11+
@ProtoNumber(3) val showModulesCount: Boolean = true,
12+
@ProtoNumber(4) val showUpdatedTime: Boolean = true,
13+
@ProtoNumber(5) val showCover: Boolean = true,
1214
)
Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
package com.dergoogler.mmrl.datastore.model
22

3+
import kotlinx.serialization.ExperimentalSerializationApi
34
import kotlinx.serialization.Serializable
5+
import kotlinx.serialization.protobuf.ProtoNumber
46

57
@Serializable
6-
data class RepositoryMenu(
7-
val option: Option = Option.Name,
8-
val descending: Boolean = false,
9-
val pinInstalled: Boolean = true,
10-
val pinUpdatable: Boolean = true,
11-
val showIcon: Boolean = true,
12-
val showLicense: Boolean = true,
13-
val showUpdatedTime: Boolean = false,
14-
val showCover: Boolean = true,
15-
val showVerified: Boolean = true,
16-
val showAntiFeatures: Boolean = true,
17-
val repoListMode: RepoListMode = RepoListMode.Compact
8+
data class RepositoryMenu @OptIn(ExperimentalSerializationApi::class) constructor(
9+
@ProtoNumber(1) val option: Option = Option.Name,
10+
@ProtoNumber(2) val descending: Boolean = false,
11+
@ProtoNumber(3) val pinInstalled: Boolean = true,
12+
@ProtoNumber(4) val pinUpdatable: Boolean = true,
13+
@ProtoNumber(5) val showIcon: Boolean = true,
14+
@ProtoNumber(6) val showLicense: Boolean = true,
15+
@ProtoNumber(7) val showUpdatedTime: Boolean = false,
16+
@ProtoNumber(8) val showCover: Boolean = true,
17+
@ProtoNumber(9) val showVerified: Boolean = true,
18+
@ProtoNumber(10) val showAntiFeatures: Boolean = true,
19+
@ProtoNumber(11) val repoListMode: RepoListMode = RepoListMode.Detailed
1820
)

app/src/main/kotlin/com/dergoogler/mmrl/datastore/model/UserPreferences.kt

Lines changed: 34 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -19,42 +19,39 @@ import kotlin.contracts.contract
1919

2020
@Serializable
2121
data class UserPreferences @OptIn(ExperimentalSerializationApi::class) constructor(
22-
val workingMode: WorkingMode = WorkingMode.FIRST_SETUP,
23-
val darkMode: DarkMode = DarkMode.FollowSystem,
24-
val themeColor: Int = if (BuildCompat.atLeastS) Colors.Dynamic.id else Colors.MMRLBase.id,
25-
val deleteZipFile: Boolean = false,
26-
val downloadPath: String = Const.PUBLIC_DOWNLOADS.path,
27-
val homepage: Homepage = Homepage.Home,
28-
@ProtoNumber(20)
29-
val repositoryMenu: RepositoryMenu = RepositoryMenu(),
30-
@ProtoNumber(30)
31-
val modulesMenu: ModulesMenu = ModulesMenu(),
32-
@ProtoNumber(40)
33-
val repositoriesMenu: RepositoriesMenu = RepositoriesMenu(),
34-
val useDoh: Boolean = false,
35-
val confirmReboot: Boolean = true,
36-
val terminalTextWrap: Boolean = false,
37-
val datePattern: String = "d MMMM yyyy",
38-
val autoUpdateRepos: Boolean = false,
39-
val autoUpdateReposInterval: Int = 0,
40-
val checkModuleUpdates: Boolean = false,
41-
val checkModuleUpdatesInterval: Int = 0,
42-
val checkAppUpdates: Boolean = true,
43-
val checkAppUpdatesPreReleases: Boolean = false,
44-
val hideFingerprintInHome: Boolean = true,
45-
val webUiDevUrl: String = "https://127.0.0.1:8080",
46-
val developerMode: Boolean = false,
47-
val useWebUiDevUrl: Boolean = false,
48-
val useShellForModuleStateChange: Boolean = false,
49-
val useShellForModuleAction: Boolean = true,
50-
val clearInstallTerminal: Boolean = true,
51-
val allowCancelInstall: Boolean = false,
52-
val allowCancelAction: Boolean = false,
53-
val blacklistAlerts: Boolean = true,
54-
val injectEruda: List<String> = emptyList(),
55-
val allowedFsModules: List<String> = emptyList(),
56-
val allowedKsuModules: List<String> = emptyList(),
57-
val useProviderAsBackgroundService: Boolean = false,
22+
@ProtoNumber(1) val workingMode: WorkingMode = WorkingMode.FIRST_SETUP,
23+
@ProtoNumber(2) val darkMode: DarkMode = DarkMode.FollowSystem,
24+
@ProtoNumber(3) val themeColor: Int = if (BuildCompat.atLeastS) Colors.Dynamic.id else Colors.MMRLBase.id,
25+
@ProtoNumber(4) val deleteZipFile: Boolean = false,
26+
@ProtoNumber(5) val downloadPath: String = Const.PUBLIC_DOWNLOADS.path,
27+
@ProtoNumber(6) val homepage: Homepage = Homepage.Home,
28+
@ProtoNumber(7) val repositoryMenu: RepositoryMenu = RepositoryMenu(),
29+
@ProtoNumber(8) val modulesMenu: ModulesMenu = ModulesMenu(),
30+
@ProtoNumber(9) val repositoriesMenu: RepositoriesMenu = RepositoriesMenu(),
31+
@ProtoNumber(10) val useDoh: Boolean = false,
32+
@ProtoNumber(11) val confirmReboot: Boolean = true,
33+
@ProtoNumber(12) val terminalTextWrap: Boolean = false,
34+
@ProtoNumber(13) val datePattern: String = "d MMMM yyyy",
35+
@ProtoNumber(14) val autoUpdateRepos: Boolean = false,
36+
@ProtoNumber(15) val autoUpdateReposInterval: Long = 6,
37+
@ProtoNumber(16) val checkModuleUpdates: Boolean = false,
38+
@ProtoNumber(17) val checkModuleUpdatesInterval: Long = 6,
39+
@ProtoNumber(18) val checkAppUpdates: Boolean = true,
40+
@ProtoNumber(19) val checkAppUpdatesPreReleases: Boolean = false,
41+
@ProtoNumber(20) val hideFingerprintInHome: Boolean = true,
42+
@ProtoNumber(21) val webUiDevUrl: String = "https://127.0.0.1:8080",
43+
@ProtoNumber(22) val developerMode: Boolean = false,
44+
@ProtoNumber(23) val useWebUiDevUrl: Boolean = false,
45+
@ProtoNumber(24) val useShellForModuleStateChange: Boolean = false,
46+
@ProtoNumber(25) val useShellForModuleAction: Boolean = true,
47+
@ProtoNumber(26) val clearInstallTerminal: Boolean = true,
48+
@ProtoNumber(27) val allowCancelInstall: Boolean = false,
49+
@ProtoNumber(28) val allowCancelAction: Boolean = false,
50+
@ProtoNumber(29) val blacklistAlerts: Boolean = true,
51+
@ProtoNumber(30) val injectEruda: List<String> = emptyList(),
52+
@ProtoNumber(31) val allowedFsModules: List<String> = emptyList(),
53+
@ProtoNumber(32) val allowedKsuModules: List<String> = emptyList(),
54+
@ProtoNumber(33) val useProviderAsBackgroundService: Boolean = false,
5855
) {
5956
@Composable
6057
fun isDarkMode() = when (darkMode) {
@@ -98,7 +95,7 @@ inline fun <R> UserPreferences.developerMode(
9895

9996
@OptIn(ExperimentalContracts::class)
10097
inline fun UserPreferences.developerMode(
101-
also: UserPreferences.() -> Boolean
98+
also: UserPreferences.() -> Boolean,
10299
): Boolean {
103100
contract {
104101
callsInPlace(also, InvocationKind.AT_MOST_ONCE)

app/src/main/kotlin/com/dergoogler/mmrl/repository/UserPreferencesRepository.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ class UserPreferencesRepository @Inject constructor(
3838
suspend fun setAutoUpdateRepos(value: Boolean) =
3939
userPreferencesDataSource.setAutoUpdateRepos(value)
4040

41-
suspend fun setAutoUpdateReposInterval(value: Int) =
41+
suspend fun setAutoUpdateReposInterval(value: Long) =
4242
userPreferencesDataSource.setAutoUpdateReposInterval(value)
4343

4444
suspend fun setCheckModuleUpdates(value: Boolean) =
4545
userPreferencesDataSource.setCheckModuleUpdates(value)
4646

47-
suspend fun setCheckModuleUpdatesInterval(value: Int) =
47+
suspend fun setCheckModuleUpdatesInterval(value: Long) =
4848
userPreferencesDataSource.setCheckModuleUpdatesInterval(value)
4949

5050
suspend fun setCheckAppUpdates(value: Boolean) =

0 commit comments

Comments
 (0)