Skip to content

Commit

Permalink
Don't pass libsu and shizuku to :app
Browse files Browse the repository at this point in the history
  • Loading branch information
Iamlooker committed Sep 20, 2023
1 parent 933aeda commit 859270f
Show file tree
Hide file tree
Showing 19 changed files with 57 additions and 25 deletions.
9 changes: 5 additions & 4 deletions app/src/main/kotlin/com/looker/droidify/MainApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ import com.looker.droidify.sync.toJobNetworkType
import com.looker.droidify.utility.extension.toInstalledItem
import com.looker.droidify.work.CleanUpWorker
import com.looker.installer.InstallManager
import com.looker.installer.installers.root.RootPermissionHandler
import com.looker.installer.installers.shizuku.ShizukuPermissionHandler
import com.looker.network.Downloader
import com.topjohnwu.superuser.Shell
import dagger.hilt.android.HiltAndroidApp
import kotlinx.coroutines.*
import kotlinx.coroutines.flow.*
Expand Down Expand Up @@ -63,6 +63,9 @@ class MainApplication : Application(), ImageLoaderFactory, Configuration.Provide
@Inject
lateinit var shizukuPermissionHandler: ShizukuPermissionHandler

@Inject
lateinit var rootPermissionHandler: RootPermissionHandler

@Inject
lateinit var workerFactory: HiltWorkerFactory

Expand Down Expand Up @@ -92,9 +95,7 @@ class MainApplication : Application(), ImageLoaderFactory, Configuration.Provide
settingsRepository.get { installerType }.collect {
if (it == InstallerType.SHIZUKU) handleShizukuInstaller()
if (it == InstallerType.ROOT) {
Shell.getCachedShell() ?: Shell.getShell()
val isRooted = Shell.isAppGrantedRoot() ?: false
if (!isRooted) {
if (!rootPermissionHandler.isGranted) {
settingsRepository.setInstallerType(InstallerType.Default)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,15 @@ import com.looker.core.datastore.SettingsRepository
import com.looker.core.model.InstalledItem
import com.looker.core.model.Product
import com.looker.core.model.Repository
import com.looker.core.model.newer.toPackageName
import com.looker.core.common.toPackageName
import com.looker.droidify.BuildConfig
import com.looker.droidify.database.Database
import com.looker.installer.InstallManager
import com.looker.installer.model.InstallerQueueState
import com.looker.installer.model.installFrom
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.onStart
import kotlinx.coroutines.launch
import javax.inject.Inject

Expand Down
9 changes: 6 additions & 3 deletions build-logic/structure/src/main/kotlin/Libs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,6 @@ private object Lifecycle {
object Others {
const val libsu = "com.github.topjohnwu.libsu:core:5.2.1"
const val zoomage = "com.jsibbold:zoomage:1.3.1"
private const val shizukuVersion = "13.0.0"
const val shizukuApi = "dev.rikka.shizuku:api:$shizukuVersion"
const val shizukuProvider = "dev.rikka.shizuku:provider:$shizukuVersion"
}

private object Room {
Expand All @@ -110,6 +107,12 @@ private object Room {
const val ktx = "androidx.room:room-ktx:$roomVersion"
}

object Shizuku {
private const val version = "13.0.0"
const val api = "dev.rikka.shizuku:api:$version"
const val provider = "dev.rikka.shizuku:provider:$version"
}

object SQLite {
private const val version = "2.3.1"
const val ktx = "androidx.sqlite:sqlite-ktx:$version"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.looker.core.model.newer
package com.looker.core.common

@JvmInline
value class PackageName(val name: String)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.looker.core.data.fdroid.repository
import com.looker.core.model.newer.App
import com.looker.core.model.newer.Author
import com.looker.core.model.newer.Package
import com.looker.core.model.newer.PackageName
import com.looker.core.common.PackageName
import kotlinx.coroutines.flow.Flow

interface AppRepository {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.looker.core.data.fdroid.repository.offline

import com.looker.core.common.PackageName
import com.looker.core.data.fdroid.repository.AppRepository
import com.looker.core.database.dao.AppDao
import com.looker.core.database.dao.InstalledDao
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.looker.core.database.model
import androidx.room.ColumnInfo
import androidx.room.Entity
import com.looker.core.common.nullIfEmpty
import com.looker.core.common.toPackageName
import com.looker.core.database.utils.localizedValue
import com.looker.core.model.newer.*

Expand Down
4 changes: 4 additions & 0 deletions core/model/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,8 @@ android {
isMinifyEnabled = true
}
}
}

dependencies {
modules(Modules.coreCommon)
}
2 changes: 2 additions & 0 deletions core/model/src/main/java/com/looker/core/model/newer/App.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.looker.core.model.newer

import com.looker.core.common.PackageName

data class App(
val repoId: Long,
val categories: List<String>,
Expand Down
9 changes: 5 additions & 4 deletions installer/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ android {
}

dependencies {
modules(Modules.coreCommon, Modules.coreDatastore, Modules.coreModel)
modules(Modules.coreCommon, Modules.coreDatastore)

implementation(AndroidX.appCompat)
coroutines()

api(Others.libsu)
implementation(Others.libsu)

api(Others.shizukuApi)
api(Others.shizukuProvider)
implementation(Shizuku.api)
api(Shizuku.provider)
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ import com.looker.core.common.extension.notificationManager
import com.looker.core.common.extension.updateAsMutable
import com.looker.core.datastore.SettingsRepository
import com.looker.core.datastore.model.InstallerType
import com.looker.core.model.newer.PackageName
import com.looker.core.common.PackageName
import com.looker.installer.installers.*
import com.looker.installer.installers.root.RootInstaller
import com.looker.installer.installers.shizuku.ShizukuInstaller
import com.looker.installer.model.*
import kotlinx.coroutines.CoroutineScope
Expand Down
5 changes: 5 additions & 0 deletions installer/src/main/java/com/looker/installer/InstallModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.looker.installer

import android.content.Context
import com.looker.core.datastore.SettingsRepository
import com.looker.installer.installers.root.RootPermissionHandler
import com.looker.installer.installers.shizuku.ShizukuPermissionHandler
import dagger.Module
import dagger.Provides
Expand All @@ -26,4 +27,8 @@ object InstallModule {
fun provideShizukuPermissionHandler(
@ApplicationContext context: Context
): ShizukuPermissionHandler = ShizukuPermissionHandler(context)

@Singleton
@Provides
fun provideRootPermissionHandler(): RootPermissionHandler = RootPermissionHandler()
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.looker.installer.installers

import com.looker.core.model.newer.PackageName
import com.looker.core.common.PackageName
import com.looker.installer.model.InstallItem
import com.looker.installer.model.InstallState

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import android.util.AndroidRuntimeException
import androidx.core.net.toUri
import com.looker.core.common.SdkCheck
import com.looker.core.common.cache.Cache
import com.looker.core.model.newer.PackageName
import com.looker.core.common.PackageName
import com.looker.installer.model.InstallItem
import com.looker.installer.model.InstallState
import kotlinx.coroutines.suspendCancellableCoroutine
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import android.os.Looper
import com.looker.core.common.SdkCheck
import com.looker.core.common.cache.Cache
import com.looker.core.common.sdkAbove
import com.looker.core.model.newer.PackageName
import com.looker.core.common.PackageName
import com.looker.installer.model.InstallItem
import com.looker.installer.model.InstallState
import kotlinx.coroutines.suspendCancellableCoroutine
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package com.looker.installer.installers
package com.looker.installer.installers.root

import android.content.Context
import com.looker.core.common.SdkCheck
import com.looker.core.common.cache.Cache
import com.looker.core.model.newer.PackageName
import com.looker.core.common.PackageName
import com.looker.installer.installers.Installer
import com.looker.installer.installers.uninstallPackage
import com.looker.installer.model.InstallItem
import com.looker.installer.model.InstallState
import com.topjohnwu.superuser.Shell
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.looker.installer.installers.root

import com.topjohnwu.superuser.Shell

class RootPermissionHandler {

val isGranted: Boolean
get() {
Shell.getCachedShell() ?: Shell.getShell()
return Shell.isAppGrantedRoot() ?: false
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.looker.installer.installers.shizuku
import android.content.Context
import com.looker.core.common.SdkCheck
import com.looker.core.common.cache.Cache
import com.looker.core.model.newer.PackageName
import com.looker.core.common.PackageName
import com.looker.installer.installers.Installer
import com.looker.installer.installers.uninstallPackage
import com.looker.installer.model.InstallItem
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.looker.installer.model

import com.looker.core.model.newer.PackageName
import com.looker.core.model.newer.toPackageName
import com.looker.core.common.PackageName
import com.looker.core.common.toPackageName

data class InstallItem(
val packageName: PackageName,
Expand Down

0 comments on commit 859270f

Please sign in to comment.