├── app
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── values
│ │ │ │ ├── strings.xml
│ │ │ │ ├── themes.xml
│ │ │ │ └── colors.xml
│ │ │ ├── mipmap-hdpi
│ │ │ │ ├── ic_launcher.webp
│ │ │ │ └── ic_launcher_round.webp
│ │ │ ├── mipmap-mdpi
│ │ │ │ ├── ic_launcher.webp
│ │ │ │ └── ic_launcher_round.webp
│ │ │ ├── mipmap-xhdpi
│ │ │ │ ├── ic_launcher.webp
│ │ │ │ └── ic_launcher_round.webp
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ ├── ic_launcher.webp
│ │ │ │ └── ic_launcher_round.webp
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ ├── ic_launcher.webp
│ │ │ │ └── ic_launcher_round.webp
│ │ │ ├── mipmap-anydpi-v26
│ │ │ │ ├── ic_launcher.xml
│ │ │ │ └── ic_launcher_round.xml
│ │ │ ├── xml
│ │ │ │ ├── backup_rules.xml
│ │ │ │ └── data_extraction_rules.xml
│ │ │ ├── drawable-v24
│ │ │ │ └── ic_launcher_foreground.xml
│ │ │ └── drawable
│ │ │ │ └── ic_launcher_background.xml
│ │ ├── java
│ │ │ └── me
│ │ │ │ └── kz
│ │ │ │ └── shizukuactivitymanager
│ │ │ │ ├── Item.kt
│ │ │ │ ├── ui
│ │ │ │ └── theme
│ │ │ │ │ ├── Color.kt
│ │ │ │ │ ├── Type.kt
│ │ │ │ │ └── Theme.kt
│ │ │ │ ├── App.kt
│ │ │ │ ├── di
│ │ │ │ └── AppModule.kt
│ │ │ │ ├── AppIconFetcherFactory.kt
│ │ │ │ ├── MainActivity.kt
│ │ │ │ ├── Api.kt
│ │ │ │ ├── RouteViewModel.kt
│ │ │ │ ├── MainViewModel.kt
│ │ │ │ └── Route.kt
│ │ └── AndroidManifest.xml
│ ├── test
│ │ └── java
│ │ │ └── me
│ │ │ └── kz
│ │ │ └── shizukuactivitymanager
│ │ │ └── ExampleUnitTest.kt
│ └── androidTest
│ │ └── java
│ │ └── me
│ │ └── kz
│ │ └── shizukuactivitymanager
│ │ └── ExampleInstrumentedTest.kt
├── proguard-rules.pro
└── build.gradle
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── README.md
├── settings.gradle
├── gradle.properties
├── .gitignore
├── gradlew.bat
└── gradlew
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | ShizukuActivityManager
3 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kzaemrio/ShizukuActivityManager/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kzaemrio/ShizukuActivityManager/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kzaemrio/ShizukuActivityManager/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kzaemrio/ShizukuActivityManager/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kzaemrio/ShizukuActivityManager/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kzaemrio/ShizukuActivityManager/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kzaemrio/ShizukuActivityManager/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kzaemrio/ShizukuActivityManager/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kzaemrio/ShizukuActivityManager/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kzaemrio/ShizukuActivityManager/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kzaemrio/ShizukuActivityManager/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/values/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/java/me/kz/shizukuactivitymanager/Item.kt:
--------------------------------------------------------------------------------
1 | package me.kz.shizukuactivitymanager
2 |
3 | import android.content.pm.PackageInfo
4 |
5 | data class Item(val appName: String, val pgName: String, val packageInfo: PackageInfo)
6 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Jul 11 10:29:19 CST 2022
2 | distributionBase=GRADLE_USER_HOME
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
4 | distributionPath=wrapper/dists
5 | zipStorePath=wrapper/dists
6 | zipStoreBase=GRADLE_USER_HOME
7 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/java/me/kz/shizukuactivitymanager/ui/theme/Color.kt:
--------------------------------------------------------------------------------
1 | package me.kz.shizukuactivitymanager.ui.theme
2 |
3 | import androidx.compose.ui.graphics.Color
4 |
5 | val Purple80 = Color(0xFFD0BCFF)
6 | val PurpleGrey80 = Color(0xFFCCC2DC)
7 | val Pink80 = Color(0xFFEFB8C8)
8 |
9 | val Purple40 = Color(0xFF6650a4)
10 | val PurpleGrey40 = Color(0xFF625b71)
11 | val Pink40 = Color(0xFF7D5260)
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FFBB86FC
4 | #FF6200EE
5 | #FF3700B3
6 | #FF03DAC5
7 | #FF018786
8 | #FF000000
9 | #FFFFFFFF
10 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # ShizukuActivityManager
2 |
3 | execute `IActivityManager.forceStopPackage` and `iActivityManager.clearApplicationUserData`
4 | by [Shizuku](https://github.com/RikkaApps/Shizuku)
5 | and [AndroidHiddenApiBypass](https://github.com/LSPosed/AndroidHiddenApiBypass)
6 |
7 | why: some app are blocking clearApplicationUserData function by
8 | adding `` to manifest file
9 |
--------------------------------------------------------------------------------
/app/src/test/java/me/kz/shizukuactivitymanager/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package me.kz.shizukuactivitymanager
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * See [testing documentation](http://d.android.com/tools/testing).
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 |
2 | pluginManagement {
3 | repositories {
4 | gradlePluginPortal()
5 | google()
6 | mavenCentral()
7 | }
8 | }
9 |
10 | dependencyResolutionManagement {
11 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
12 | repositories {
13 | google()
14 | mavenCentral()
15 | maven { url 'https://jitpack.io' }
16 | }
17 | }
18 |
19 | rootProject.name = "ShizukuActivityManager"
20 |
21 | include ':app'
22 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/backup_rules.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/data_extraction_rules.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
12 |
13 |
19 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
--------------------------------------------------------------------------------
/app/src/androidTest/java/me/kz/shizukuactivitymanager/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package me.kz.shizukuactivitymanager
2 |
3 | import androidx.test.platform.app.InstrumentationRegistry
4 | import androidx.test.ext.junit.runners.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Instrumented test, which will execute on an Android device.
13 | *
14 | * See [testing documentation](http://d.android.com/tools/testing).
15 | */
16 | @RunWith(AndroidJUnit4::class)
17 | class ExampleInstrumentedTest {
18 | @Test
19 | fun useAppContext() {
20 | // Context of the app under test.
21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22 | assertEquals("me.kz.shizukuactivitymanager", appContext.packageName)
23 | }
24 | }
--------------------------------------------------------------------------------
/app/src/main/java/me/kz/shizukuactivitymanager/App.kt:
--------------------------------------------------------------------------------
1 | package me.kz.shizukuactivitymanager
2 |
3 | import android.app.Application
4 | import coil.Coil
5 | import coil.ImageLoader
6 | import dagger.hilt.android.HiltAndroidApp
7 | import kotlinx.coroutines.CoroutineDispatcher
8 | import javax.inject.Inject
9 |
10 | @HiltAndroidApp
11 | class App : Application() {
12 |
13 | @Inject
14 | lateinit var dispatcher: CoroutineDispatcher
15 |
16 | override fun onCreate() {
17 | super.onCreate()
18 | Coil.setImageLoader {
19 | ImageLoader(this@App).newBuilder()
20 | .components {
21 | add(AppIconFetcherFactory(this@App))
22 | }
23 | .interceptorDispatcher(dispatcher)
24 | .dispatcher(dispatcher)
25 | .build()
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/app/src/main/java/me/kz/shizukuactivitymanager/ui/theme/Type.kt:
--------------------------------------------------------------------------------
1 | package me.kz.shizukuactivitymanager.ui.theme
2 |
3 | import androidx.compose.material.Typography
4 | import androidx.compose.ui.text.TextStyle
5 | import androidx.compose.ui.text.font.FontFamily
6 | import androidx.compose.ui.text.font.FontWeight
7 | import androidx.compose.ui.unit.sp
8 |
9 | // Set of Material typography styles to start with
10 | val Typography = Typography(
11 | body1 = TextStyle(
12 | fontFamily = FontFamily.Default,
13 | fontWeight = FontWeight.Normal,
14 | fontSize = 16.sp,
15 | lineHeight = 24.sp,
16 | letterSpacing = 0.5.sp
17 | )
18 | /* Other default text styles to override
19 | titleLarge = TextStyle(
20 | fontFamily = FontFamily.Default,
21 | fontWeight = FontWeight.Normal,
22 | fontSize = 22.sp,
23 | lineHeight = 28.sp,
24 | letterSpacing = 0.sp
25 | ),
26 | labelSmall = TextStyle(
27 | fontFamily = FontFamily.Default,
28 | fontWeight = FontWeight.Medium,
29 | fontSize = 11.sp,
30 | lineHeight = 16.sp,
31 | letterSpacing = 0.5.sp
32 | )
33 | */
34 | )
--------------------------------------------------------------------------------
/app/src/main/java/me/kz/shizukuactivitymanager/di/AppModule.kt:
--------------------------------------------------------------------------------
1 | package me.kz.shizukuactivitymanager.di
2 |
3 | import android.content.Context
4 | import android.content.pm.PackageManager
5 | import dagger.Module
6 | import dagger.Provides
7 | import dagger.hilt.InstallIn
8 | import dagger.hilt.android.qualifiers.ApplicationContext
9 | import dagger.hilt.components.SingletonComponent
10 | import kotlinx.coroutines.CoroutineDispatcher
11 | import kotlinx.coroutines.asCoroutineDispatcher
12 | import java.util.concurrent.Executor
13 | import java.util.concurrent.ExecutorService
14 | import java.util.concurrent.Executors
15 | import javax.inject.Singleton
16 |
17 |
18 | @Module
19 | @InstallIn(SingletonComponent::class)
20 | object AppModule {
21 |
22 | @Provides
23 | @Singleton
24 | fun bindExecutorService(executor: Executor): ExecutorService = executor as ExecutorService
25 |
26 | @Provides
27 | @Singleton
28 | fun bindDispatcher(executor: Executor): CoroutineDispatcher = executor.asCoroutineDispatcher()
29 |
30 | @Provides
31 | @Singleton
32 | fun provideExecutor(): Executor {
33 | return Executors.newSingleThreadExecutor {
34 | Thread(it, "bg-single-thread")
35 | }
36 | }
37 |
38 | @Provides
39 | @Singleton
40 | fun packageManager(@ApplicationContext context: Context): PackageManager =
41 | context.packageManager
42 | }
43 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 | # AndroidX package structure to make it clearer which packages are bundled with the
15 | # Android operating system, and which are packaged with your app"s APK
16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
17 | android.useAndroidX=true
18 | # Kotlin code style for this project: "official" or "obsolete":
19 | kotlin.code.style=official
20 | # Enables namespacing of each library's R class so that its R class includes only the
21 | # resources declared in the library itself and none from the library's dependencies,
22 | # thereby reducing the size of the R class for that library
23 | android.nonTransitiveRClass=true
--------------------------------------------------------------------------------
/app/src/main/java/me/kz/shizukuactivitymanager/AppIconFetcherFactory.kt:
--------------------------------------------------------------------------------
1 | package me.kz.shizukuactivitymanager
2 |
3 | import android.content.Context
4 | import android.content.pm.PackageInfo
5 | import android.content.res.Resources
6 | import android.graphics.drawable.BitmapDrawable
7 | import coil.ImageLoader
8 | import coil.decode.DataSource
9 | import coil.fetch.DrawableResult
10 | import coil.fetch.FetchResult
11 | import coil.fetch.Fetcher
12 | import coil.request.Options
13 | import me.zhanghai.android.appiconloader.AppIconLoader
14 |
15 | class AppIconFetcherFactory(private val context: Context) : Fetcher.Factory {
16 |
17 | private val loader = AppIconLoader(40.dp, false, context)
18 |
19 | override fun create(data: PackageInfo, options: Options, imageLoader: ImageLoader): Fetcher {
20 | return AppIconFetcher(context, data, loader)
21 | }
22 | }
23 |
24 | class AppIconFetcher(
25 | private val context: Context,
26 | private val info: PackageInfo,
27 | private val loader: AppIconLoader
28 | ) : Fetcher {
29 | override suspend fun fetch(): FetchResult {
30 | return DrawableResult(
31 | BitmapDrawable(
32 | context.resources,
33 | loader.loadIcon(info.applicationInfo)
34 | ),
35 | true,
36 | DataSource.DISK
37 | )
38 | }
39 | }
40 |
41 | val Number.dp: Int get() = (toInt() * Resources.getSystem().displayMetrics.density).toInt()
42 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
6 |
17 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/app/src/main/java/me/kz/shizukuactivitymanager/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package me.kz.shizukuactivitymanager
2 |
3 | import android.os.Bundle
4 | import androidx.activity.ComponentActivity
5 | import androidx.activity.compose.setContent
6 | import androidx.compose.foundation.layout.fillMaxSize
7 | import androidx.compose.material.MaterialTheme
8 | import androidx.compose.material.Surface
9 | import androidx.compose.material.Text
10 | import androidx.compose.runtime.Composable
11 | import androidx.compose.ui.Modifier
12 | import androidx.compose.ui.tooling.preview.Preview
13 | import dagger.hilt.android.AndroidEntryPoint
14 | import me.kz.shizukuactivitymanager.ui.theme.ShizukuActivityManagerTheme
15 |
16 | private const val TAG = "MainActivity"
17 |
18 | @AndroidEntryPoint
19 | class MainActivity : ComponentActivity() {
20 | override fun onCreate(savedInstanceState: Bundle?) {
21 | super.onCreate(savedInstanceState)
22 |
23 | setContent {
24 | ShizukuActivityManagerTheme {
25 | // A surface container using the 'background' color from the theme
26 | Surface(
27 | modifier = Modifier.fillMaxSize(),
28 | color = MaterialTheme.colors.background
29 | ) {
30 | Route()
31 | }
32 | }
33 | }
34 | }
35 | }
36 |
37 | @Composable
38 | fun Greeting(name: String) {
39 | Text(text = "Hello $name!")
40 | }
41 |
42 | @Preview(showBackground = true)
43 | @Composable
44 | fun DefaultPreview() {
45 | ShizukuActivityManagerTheme {
46 | Greeting("Android")
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/app/src/main/java/me/kz/shizukuactivitymanager/Api.kt:
--------------------------------------------------------------------------------
1 | package me.kz.shizukuactivitymanager
2 |
3 | import android.app.ActivityManagerNative
4 | import android.app.IActivityManager
5 | import android.content.Context
6 | import android.content.pm.IPackageManager
7 | import android.content.pm.PackageInfo
8 | import android.content.pm.PackageManager
9 | import android.content.pm.ParceledListSlice
10 | import org.lsposed.hiddenapibypass.HiddenApiBypass
11 | import rikka.shizuku.ShizukuBinderWrapper
12 | import rikka.shizuku.SystemServiceHelper
13 | import javax.inject.Inject
14 |
15 | class Api @Inject constructor() {
16 | private val iActivityManager: IActivityManager = ActivityManagerNative.asInterface(
17 | ShizukuBinderWrapper(
18 | SystemServiceHelper.getSystemService(Context.ACTIVITY_SERVICE)
19 | )
20 | )
21 |
22 | private val iPackageManager: IPackageManager = IPackageManager.Stub.asInterface(
23 | ShizukuBinderWrapper(
24 | SystemServiceHelper.getSystemService("package")
25 | )
26 | )
27 |
28 | fun clearApplicationUserData(pgName: String) {
29 | HiddenApiBypass.invoke(
30 | IActivityManager::class.java,
31 | iActivityManager,
32 | "clearApplicationUserData",
33 | pgName, false, null, 0
34 | )
35 | }
36 |
37 | fun forceStopPackage(pgName: String) {
38 | iActivityManager.forceStopPackage(pgName, 0)
39 | }
40 |
41 | @Suppress("UNCHECKED_CAST")
42 | fun getInstalledPackages(): List {
43 | return HiddenApiBypass.invoke(
44 | ParceledListSlice::class.java,
45 | iPackageManager.getInstalledPackages(PackageManager.GET_META_DATA, 0),
46 | "getList"
47 | ) as List
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
15 |
18 |
21 |
22 |
23 |
24 |
30 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 |
2 | *.DS_Store
3 |
4 | # Built application files
5 | *.apk
6 | *.aar
7 | *.ap_
8 | *.aab
9 |
10 | # Files for the ART/Dalvik VM
11 | *.dex
12 |
13 | # Java class files
14 | *.class
15 |
16 | # Generated files
17 | bin/
18 | gen/
19 | out/
20 | app/release/
21 | # Uncomment the following line in case you need and you don't have the release build type files in your app
22 | # release/
23 |
24 | # Gradle files
25 | .gradle/
26 | build/
27 |
28 | # Local configuration file (sdk path, etc)
29 | local.properties
30 |
31 | # Proguard folder generated by Eclipse
32 | proguard/
33 |
34 | # Log Files
35 | *.log
36 |
37 | # Android Studio Navigation editor temp files
38 | .navigation/
39 |
40 | # Android Studio captures folder
41 | captures/
42 |
43 | # IntelliJ
44 | *.iml
45 | .idea/
46 | .idea/workspace.xml
47 | .idea/tasks.xml
48 | .idea/gradle.xml
49 | .idea/assetWizardSettings.xml
50 | .idea/dictionaries
51 | .idea/libraries
52 | # Android Studio 3 in .gitignore file.
53 | .idea/caches
54 | .idea/modules.xml
55 | # Comment next line if keeping position of elements in Navigation Editor is relevant for you
56 | .idea/navEditor.xml
57 |
58 | # Keystore files
59 | # Uncomment the following lines if you do not want to check your keystore files in.
60 | #*.jks
61 | #*.keystore
62 |
63 | # External native build folder generated in Android Studio 2.2 and later
64 | .externalNativeBuild
65 | .cxx/
66 |
67 | # Google Services (e.g. APIs or Firebase)
68 | # google-services.json
69 |
70 | # Freeline
71 | freeline.py
72 | freeline/
73 | freeline_project_description.json
74 |
75 | # fastlane
76 | fastlane/report.xml
77 | fastlane/Preview.html
78 | fastlane/screenshots
79 | fastlane/test_output
80 | fastlane/readme.md
81 |
82 | # Version control
83 | vcs.xml
84 |
85 | # lint
86 | lint/intermediates/
87 | lint/generated/
88 | lint/outputs/
89 | lint/tmp/
90 | # lint/reports/
91 |
92 | # Android Profiling
93 | *.hprof
--------------------------------------------------------------------------------
/app/src/main/java/me/kz/shizukuactivitymanager/ui/theme/Theme.kt:
--------------------------------------------------------------------------------
1 | package me.kz.shizukuactivitymanager.ui.theme
2 |
3 | import android.app.Activity
4 | import android.os.Build
5 | import androidx.compose.foundation.isSystemInDarkTheme
6 | import androidx.compose.material.MaterialTheme
7 | import androidx.compose.material.darkColors
8 | import androidx.compose.material.lightColors
9 | import androidx.compose.runtime.Composable
10 | import androidx.compose.runtime.SideEffect
11 | import androidx.compose.ui.graphics.toArgb
12 | import androidx.compose.ui.platform.LocalContext
13 | import androidx.compose.ui.platform.LocalView
14 | import androidx.core.view.ViewCompat
15 |
16 | private val DarkColorScheme = darkColors(
17 | primary = Purple80,
18 | secondary = PurpleGrey80,
19 | )
20 |
21 | private val LightColorScheme = lightColors(
22 | primary = Purple40,
23 | secondary = PurpleGrey40,
24 |
25 | /* Other default colors to override
26 | background = Color(0xFFFFFBFE),
27 | surface = Color(0xFFFFFBFE),
28 | onPrimary = Color.White,
29 | onSecondary = Color.White,
30 | onTertiary = Color.White,
31 | onBackground = Color(0xFF1C1B1F),
32 | onSurface = Color(0xFF1C1B1F),
33 | */
34 | )
35 |
36 | @Composable
37 | fun ShizukuActivityManagerTheme(
38 | darkTheme: Boolean = isSystemInDarkTheme(),
39 | content: @Composable () -> Unit
40 | ) {
41 | val colorScheme = when {
42 | darkTheme -> DarkColorScheme
43 | else -> LightColorScheme
44 | }
45 | val view = LocalView.current
46 | if (!view.isInEditMode) {
47 | SideEffect {
48 | (view.context as Activity).window.statusBarColor = colorScheme.primary.toArgb()
49 | ViewCompat.getWindowInsetsController(view)?.isAppearanceLightStatusBars = darkTheme
50 | }
51 | }
52 |
53 | MaterialTheme(
54 | colors = colorScheme,
55 | typography = Typography,
56 | content = content
57 | )
58 | }
59 |
--------------------------------------------------------------------------------
/app/src/main/java/me/kz/shizukuactivitymanager/RouteViewModel.kt:
--------------------------------------------------------------------------------
1 | package me.kz.shizukuactivitymanager
2 |
3 | import android.content.pm.PackageManager
4 | import androidx.lifecycle.ViewModel
5 | import androidx.lifecycle.viewModelScope
6 | import dagger.hilt.android.lifecycle.HiltViewModel
7 | import kotlinx.coroutines.flow.MutableStateFlow
8 | import kotlinx.coroutines.flow.StateFlow
9 | import kotlinx.coroutines.launch
10 | import rikka.shizuku.Shizuku
11 | import javax.inject.Inject
12 | import kotlin.coroutines.resume
13 | import kotlin.coroutines.suspendCoroutine
14 |
15 | @HiltViewModel
16 | class RouteViewModel @Inject constructor() : ViewModel() {
17 |
18 | private val _flow: MutableStateFlow = MutableStateFlow(Refresh)
19 | val flow: StateFlow
20 | get() = _flow
21 |
22 | init {
23 | viewModelScope.launch {
24 | val state = try {
25 | onSelfPermission(Shizuku.checkSelfPermission())
26 | } catch (e: IllegalStateException) {
27 | Uninstall
28 | }
29 | _flow.emit(state)
30 | }
31 | }
32 |
33 | private suspend fun onSelfPermission(selfPermission: Int): UiState {
34 | return when (selfPermission) {
35 | PackageManager.PERMISSION_GRANTED -> Home
36 | PackageManager.PERMISSION_DENIED -> PermissionDeny
37 | else -> onSelfPermission(requestPermission())
38 | }
39 | }
40 |
41 | private suspend fun requestPermission(): Int = suspendCoroutine { co ->
42 | Shizuku.addRequestPermissionResultListener(object :
43 | Shizuku.OnRequestPermissionResultListener {
44 | override fun onRequestPermissionResult(
45 | requestCode: Int,
46 | grantResult: Int
47 | ) {
48 | Shizuku.removeRequestPermissionResultListener(this)
49 | co.resume(grantResult)
50 | }
51 | })
52 | Shizuku.requestPermission(2333)
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/app/src/main/java/me/kz/shizukuactivitymanager/MainViewModel.kt:
--------------------------------------------------------------------------------
1 | package me.kz.shizukuactivitymanager
2 |
3 | import android.content.pm.ApplicationInfo
4 | import android.content.pm.PackageManager
5 | import android.util.Log
6 | import androidx.lifecycle.ViewModel
7 | import androidx.lifecycle.viewModelScope
8 | import dagger.hilt.android.lifecycle.HiltViewModel
9 | import kotlinx.coroutines.CoroutineDispatcher
10 | import kotlinx.coroutines.flow.*
11 | import kotlinx.coroutines.launch
12 | import kotlinx.coroutines.withContext
13 | import javax.inject.Inject
14 |
15 | private const val TAG = "MainViewModel"
16 |
17 | @HiltViewModel
18 | class MainViewModel @Inject constructor(
19 | private val coroutineDispatcher: CoroutineDispatcher,
20 | private val api: Api,
21 | private val pm: PackageManager,
22 | ) : ViewModel() {
23 |
24 | private val _filter = MutableStateFlow("")
25 | val filter: StateFlow
26 | get() = _filter
27 |
28 | private val _list = MutableStateFlow(emptyList- ())
29 | val list: StateFlow
>
30 | get() = _list
31 |
32 | init {
33 | viewModelScope.launch {
34 | val all = withContext(coroutineDispatcher) {
35 | api.getInstalledPackages()
36 | .asSequence()
37 | .map { Item(it.applicationInfo.loadLabel(pm).toString(), it.packageName, it) }
38 | .toList()
39 | }
40 | combine(filter, flow { emit(all) }) { filterKeyWord, allList ->
41 | if (filterKeyWord.isBlank()) {
42 | allList
43 | } else {
44 | allList.filter {
45 | it.appName.contains(filterKeyWord) || it.pgName.contains(filterKeyWord)
46 | }
47 | }
48 | }.onEach { _list.emit(it) }.launchIn(this)
49 | }
50 | }
51 |
52 | fun onFilter(input: String) {
53 | viewModelScope.launch { _filter.emit(input) }
54 | }
55 |
56 | fun onClearFilter() {
57 | viewModelScope.launch { _filter.emit("") }
58 | }
59 |
60 | fun onClear(pgName: String) {
61 | api.clearApplicationUserData(pgName)
62 | }
63 |
64 | fun onStop(pgName: String) {
65 | api.forceStopPackage(pgName)
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%" == "" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%" == "" set DIRNAME=.
29 | set APP_BASE_NAME=%~n0
30 | set APP_HOME=%DIRNAME%
31 |
32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
34 |
35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
37 |
38 | @rem Find java.exe
39 | if defined JAVA_HOME goto findJavaFromJavaHome
40 |
41 | set JAVA_EXE=java.exe
42 | %JAVA_EXE% -version >NUL 2>&1
43 | if "%ERRORLEVEL%" == "0" goto execute
44 |
45 | echo.
46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
47 | echo.
48 | echo Please set the JAVA_HOME variable in your environment to match the
49 | echo location of your Java installation.
50 |
51 | goto fail
52 |
53 | :findJavaFromJavaHome
54 | set JAVA_HOME=%JAVA_HOME:"=%
55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
56 |
57 | if exist "%JAVA_EXE%" goto execute
58 |
59 | echo.
60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
61 | echo.
62 | echo Please set the JAVA_HOME variable in your environment to match the
63 | echo location of your Java installation.
64 |
65 | goto fail
66 |
67 | :execute
68 | @rem Setup the command line
69 |
70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
71 |
72 |
73 | @rem Execute Gradle
74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
75 |
76 | :end
77 | @rem End local scope for the variables with windows NT shell
78 | if "%ERRORLEVEL%"=="0" goto mainEnd
79 |
80 | :fail
81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
82 | rem the _cmd.exe /c_ return code!
83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
84 | exit /b 1
85 |
86 | :mainEnd
87 | if "%OS%"=="Windows_NT" endlocal
88 |
89 | :omega
90 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'com.android.application'
3 | id 'org.jetbrains.kotlin.android'
4 | id 'com.google.devtools.ksp'
5 | id 'kotlin-kapt'
6 | id 'dagger.hilt.android.plugin'
7 | id 'dev.rikka.tools.refine'
8 | }
9 |
10 | android {
11 | compileSdk 33
12 |
13 | defaultConfig {
14 | applicationId "me.kz.shizukuactivitymanager"
15 | minSdk 28
16 | targetSdk 33
17 | versionCode 1
18 | versionName "1.0"
19 |
20 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
21 | vectorDrawables {
22 | useSupportLibrary true
23 | }
24 | }
25 |
26 | buildTypes {
27 | release {
28 | minifyEnabled true
29 | shrinkResources true
30 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
31 | }
32 | debug {
33 | minifyEnabled false
34 | shrinkResources false
35 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
36 | }
37 | }
38 | compileOptions {
39 | sourceCompatibility JavaVersion.VERSION_1_8
40 | targetCompatibility JavaVersion.VERSION_1_8
41 | }
42 | kotlinOptions {
43 | jvmTarget = '1.8'
44 | }
45 | buildFeatures {
46 | compose true
47 | }
48 | composeOptions {
49 | kotlinCompilerExtensionVersion compose_compiler_version
50 | }
51 | packagingOptions {
52 | resources {
53 | excludes += '/META-INF/{AL2.0,LGPL2.1}'
54 | }
55 | }
56 | namespace 'me.kz.shizukuactivitymanager'
57 | }
58 |
59 | kotlin {
60 | sourceSets {
61 | debug {
62 | kotlin.srcDir("build/generated/ksp/debug/kotlin")
63 | }
64 | release {
65 | kotlin.srcDir("build/generated/ksp/release/kotlin")
66 | }
67 | }
68 | }
69 |
70 | dependencies {
71 | testImplementation 'junit:junit:4.13.2'
72 | androidTestImplementation 'androidx.test.ext:junit:1.1.3'
73 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
74 | androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"
75 | debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"
76 | debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_version"
77 | }
78 |
79 | dependencies {
80 | implementation 'androidx.core:core-ktx:1.9.0'
81 | implementation "androidx.compose.ui:ui:$compose_version"
82 | implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
83 | implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.5.1'
84 | implementation 'androidx.activity:activity-compose:1.6.1'
85 | implementation "androidx.compose.material:material:$compose_version"
86 | implementation "androidx.compose.material:material-icons-extended:$compose_version"
87 |
88 | implementation "com.google.accompanist:accompanist-swiperefresh:0.27.0"
89 |
90 | implementation "androidx.hilt:hilt-navigation-compose:1.0.0"
91 | implementation "com.google.dagger:hilt-android:$hilt_version"
92 | kapt "com.google.dagger:hilt-compiler:$hilt_version"
93 |
94 | compileOnly 'dev.rikka.hidden:stub:3.0.0'
95 | implementation "dev.rikka.shizuku:api:$shizuku_version"
96 | implementation "dev.rikka.shizuku:provider:$shizuku_version"
97 |
98 | implementation "io.coil-kt:coil-compose:2.2.2"
99 | implementation 'me.zhanghai.android.appiconloader:appiconloader:1.5.0'
100 | implementation 'me.zhanghai.android.appiconloader:appiconloader-iconloaderlib:1.5.0'
101 | implementation 'me.zhanghai.android.appiconloader:appiconloader-coil:1.4.0'
102 |
103 | implementation 'org.lsposed.hiddenapibypass:hiddenapibypass:4.3'
104 | }
105 |
--------------------------------------------------------------------------------
/app/src/main/java/me/kz/shizukuactivitymanager/Route.kt:
--------------------------------------------------------------------------------
1 | package me.kz.shizukuactivitymanager
2 |
3 | import androidx.compose.foundation.layout.*
4 | import androidx.compose.foundation.lazy.LazyColumn
5 | import androidx.compose.foundation.lazy.items
6 | import androidx.compose.material.*
7 | import androidx.compose.material.icons.Icons
8 | import androidx.compose.material.icons.rounded.Clear
9 | import androidx.compose.runtime.Composable
10 | import androidx.compose.runtime.collectAsState
11 | import androidx.compose.runtime.getValue
12 | import androidx.compose.runtime.rememberUpdatedState
13 | import androidx.compose.ui.Alignment
14 | import androidx.compose.ui.Modifier
15 | import androidx.compose.ui.graphics.Color
16 | import androidx.compose.ui.platform.LocalFocusManager
17 | import androidx.compose.ui.unit.dp
18 | import androidx.hilt.navigation.compose.hiltViewModel
19 | import coil.compose.AsyncImage
20 |
21 | @Composable
22 | fun Route(viewModel: RouteViewModel = hiltViewModel()) {
23 | when (viewModel.flow.collectAsState().value) {
24 | Refresh -> Refresh()
25 | Uninstall -> Uninstall()
26 | PermissionDeny -> PermissionDeny()
27 | Home -> Home()
28 | }
29 | }
30 |
31 | @Composable
32 | fun Home(viewModel: MainViewModel = hiltViewModel()) {
33 | Scaffold(topBar = {
34 | TopAppBar(
35 | contentPadding = PaddingValues(
36 | start = 6.dp,
37 | end = 6.dp,
38 | top = 6.dp,
39 | bottom = 10.dp
40 | )
41 | ) {
42 | val focusManager = LocalFocusManager.current
43 | val text = viewModel.filter.collectAsState().value
44 | TextField(
45 | modifier = Modifier.fillMaxWidth(),
46 | singleLine = true,
47 | colors = TextFieldDefaults.textFieldColors(
48 | backgroundColor = Color.Unspecified,
49 | cursorColor = Color.White,
50 | unfocusedIndicatorColor = Color.White,
51 | placeholderColor = Color.White
52 | ),
53 | placeholder = { Text(text = "filter") },
54 | value = text,
55 | onValueChange = viewModel::onFilter,
56 | trailingIcon = {
57 | if (text.isNotBlank()) {
58 | IconButton(onClick = {
59 | viewModel.onClearFilter()
60 | focusManager.clearFocus()
61 | }) {
62 | Icon(imageVector = Icons.Rounded.Clear, contentDescription = "clear")
63 | }
64 | }
65 | }
66 | )
67 | }
68 | }) {
69 | val list: List- by viewModel.list.collectAsState()
70 | val onClear: (String) -> Unit by rememberUpdatedState(newValue = viewModel::onClear)
71 | val stop: (String) -> Unit by rememberUpdatedState(newValue = viewModel::onStop)
72 | Home(
73 | Modifier.padding(it),
74 | list,
75 | onClear,
76 | stop
77 | )
78 | }
79 | }
80 |
81 | @Composable
82 | fun Home(
83 | modifier: Modifier = Modifier,
84 | list: List
- ,
85 | onClear: (String) -> Unit,
86 | onStop: (String) -> Unit
87 | ) {
88 | if (list.isEmpty()) {
89 | Refresh()
90 | } else {
91 | LazyColumn(modifier) {
92 | items(items = list, key = { it.pgName }) {
93 | Item(it, onClear, onStop)
94 | }
95 | }
96 | }
97 | }
98 |
99 | @Composable
100 | fun Item(
101 | item: Item,
102 | onClear: (String) -> Unit,
103 | onStop: (String) -> Unit
104 | ) {
105 | Row(
106 | modifier = Modifier
107 | .fillMaxWidth()
108 | .padding(horizontal = 16.dp, vertical = 8.dp)
109 | ) {
110 | AsyncImage(
111 | modifier = Modifier.size(40.dp),
112 | model = item.packageInfo,
113 | contentDescription = item.pgName
114 | )
115 | Spacer(modifier = Modifier.width(6.dp))
116 | Info(item, onClear, onStop)
117 | }
118 | }
119 |
120 | @Composable
121 | fun Info(
122 | item: Item,
123 | onClear: (String) -> Unit,
124 | onStop: (String) -> Unit
125 | ) {
126 | Column(Modifier.fillMaxWidth()) {
127 | Text(text = item.appName, maxLines = 1)
128 | Spacer(modifier = Modifier.height(6.dp))
129 | Text(text = item.pgName)
130 | Spacer(modifier = Modifier.height(6.dp))
131 | ButtonGroup(item, onClear, onStop)
132 | }
133 | }
134 |
135 | @Composable
136 | fun ButtonGroup(
137 | item: Item,
138 | onClear: (String) -> Unit,
139 | onStop: (String) -> Unit
140 | ) {
141 | Row(Modifier.fillMaxWidth()) {
142 | Button(
143 | modifier = Modifier.weight(1F),
144 | onClick = { onClear(item.pgName) }
145 | ) {
146 | Text(text = "clear")
147 | }
148 | Spacer(modifier = Modifier.width(6.dp))
149 | Button(
150 | modifier = Modifier.weight(1F),
151 | onClick = { onStop(item.pgName) }
152 | ) {
153 | Text(text = "stop")
154 | }
155 | }
156 | }
157 |
158 | @Composable
159 | fun PermissionDeny() {
160 | Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
161 | Text(text = "shizuku permission denied")
162 | }
163 | }
164 |
165 | @Composable
166 | fun Uninstall() {
167 | Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
168 | Text(text = "no shizuku app installed or running")
169 | }
170 | }
171 |
172 | @Composable
173 | fun Refresh() {
174 | Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
175 | CircularProgressIndicator()
176 | }
177 | }
178 |
179 | sealed interface UiState
180 | object Refresh : UiState
181 | object Uninstall : UiState
182 | object PermissionDeny : UiState
183 | object Home : UiState
184 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | #
4 | # Copyright 2015 the original author or authors.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # https://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | ##############################################################################
20 | ##
21 | ## Gradle start up script for UN*X
22 | ##
23 | ##############################################################################
24 |
25 | # Attempt to set APP_HOME
26 | # Resolve links: $0 may be a link
27 | PRG="$0"
28 | # Need this for relative symlinks.
29 | while [ -h "$PRG" ] ; do
30 | ls=`ls -ld "$PRG"`
31 | link=`expr "$ls" : '.*-> \(.*\)$'`
32 | if expr "$link" : '/.*' > /dev/null; then
33 | PRG="$link"
34 | else
35 | PRG=`dirname "$PRG"`"/$link"
36 | fi
37 | done
38 | SAVED="`pwd`"
39 | cd "`dirname \"$PRG\"`/" >/dev/null
40 | APP_HOME="`pwd -P`"
41 | cd "$SAVED" >/dev/null
42 |
43 | APP_NAME="Gradle"
44 | APP_BASE_NAME=`basename "$0"`
45 |
46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
48 |
49 | # Use the maximum available, or set MAX_FD != -1 to use that value.
50 | MAX_FD="maximum"
51 |
52 | warn () {
53 | echo "$*"
54 | }
55 |
56 | die () {
57 | echo
58 | echo "$*"
59 | echo
60 | exit 1
61 | }
62 |
63 | # OS specific support (must be 'true' or 'false').
64 | cygwin=false
65 | msys=false
66 | darwin=false
67 | nonstop=false
68 | case "`uname`" in
69 | CYGWIN* )
70 | cygwin=true
71 | ;;
72 | Darwin* )
73 | darwin=true
74 | ;;
75 | MINGW* )
76 | msys=true
77 | ;;
78 | NONSTOP* )
79 | nonstop=true
80 | ;;
81 | esac
82 |
83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
84 |
85 |
86 | # Determine the Java command to use to start the JVM.
87 | if [ -n "$JAVA_HOME" ] ; then
88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
89 | # IBM's JDK on AIX uses strange locations for the executables
90 | JAVACMD="$JAVA_HOME/jre/sh/java"
91 | else
92 | JAVACMD="$JAVA_HOME/bin/java"
93 | fi
94 | if [ ! -x "$JAVACMD" ] ; then
95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
96 |
97 | Please set the JAVA_HOME variable in your environment to match the
98 | location of your Java installation."
99 | fi
100 | else
101 | JAVACMD="java"
102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
103 |
104 | Please set the JAVA_HOME variable in your environment to match the
105 | location of your Java installation."
106 | fi
107 |
108 | # Increase the maximum file descriptors if we can.
109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
110 | MAX_FD_LIMIT=`ulimit -H -n`
111 | if [ $? -eq 0 ] ; then
112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
113 | MAX_FD="$MAX_FD_LIMIT"
114 | fi
115 | ulimit -n $MAX_FD
116 | if [ $? -ne 0 ] ; then
117 | warn "Could not set maximum file descriptor limit: $MAX_FD"
118 | fi
119 | else
120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
121 | fi
122 | fi
123 |
124 | # For Darwin, add options to specify how the application appears in the dock
125 | if $darwin; then
126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
127 | fi
128 |
129 | # For Cygwin or MSYS, switch paths to Windows format before running java
130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
133 |
134 | JAVACMD=`cygpath --unix "$JAVACMD"`
135 |
136 | # We build the pattern for arguments to be converted via cygpath
137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
138 | SEP=""
139 | for dir in $ROOTDIRSRAW ; do
140 | ROOTDIRS="$ROOTDIRS$SEP$dir"
141 | SEP="|"
142 | done
143 | OURCYGPATTERN="(^($ROOTDIRS))"
144 | # Add a user-defined pattern to the cygpath arguments
145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
147 | fi
148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
149 | i=0
150 | for arg in "$@" ; do
151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
153 |
154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
156 | else
157 | eval `echo args$i`="\"$arg\""
158 | fi
159 | i=`expr $i + 1`
160 | done
161 | case $i in
162 | 0) set -- ;;
163 | 1) set -- "$args0" ;;
164 | 2) set -- "$args0" "$args1" ;;
165 | 3) set -- "$args0" "$args1" "$args2" ;;
166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
172 | esac
173 | fi
174 |
175 | # Escape application args
176 | save () {
177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
178 | echo " "
179 | }
180 | APP_ARGS=`save "$@"`
181 |
182 | # Collect all arguments for the java command, following the shell quoting and substitution rules
183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
184 |
185 | exec "$JAVACMD" "$@"
186 |
--------------------------------------------------------------------------------