Skip to content
This repository was archived by the owner on Jul 2, 2024. It is now read-only.

Commit 39c3fe4

Browse files
committed
Enable InstallActivity only in root mode
1 parent 2ba7f37 commit 39c3fe4

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

app/src/main/kotlin/com/sanmer/mrepo/ui/activity/MainActivity.kt

+21
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.sanmer.mrepo.ui.activity
22

3+
import android.content.ComponentName
4+
import android.content.pm.PackageManager
35
import android.os.Bundle
46
import androidx.activity.ComponentActivity
57
import androidx.activity.compose.setContent
@@ -61,6 +63,7 @@ class MainActivity : ComponentActivity() {
6163

6264
ProviderCompat.init(userPreferences!!.workingMode)
6365
NetworkUtils.setEnableDoh(userPreferences!!.useDoh)
66+
setInstallActivityEnabled(userPreferences!!.isRoot)
6467
}
6568

6669
CompositionLocalProvider(
@@ -92,4 +95,22 @@ class MainActivity : ComponentActivity() {
9295
MediaStoreUtils.PermissionState()
9396
}
9497
}
98+
99+
private fun setInstallActivityEnabled(enable: Boolean) {
100+
val component = ComponentName(
101+
this, InstallActivity::class.java
102+
)
103+
104+
val state = if (enable) {
105+
PackageManager.COMPONENT_ENABLED_STATE_ENABLED
106+
} else {
107+
PackageManager.COMPONENT_ENABLED_STATE_DISABLED
108+
}
109+
110+
packageManager.setComponentEnabledSetting(
111+
component,
112+
state,
113+
PackageManager.DONT_KILL_APP
114+
)
115+
}
95116
}

0 commit comments

Comments
 (0)